# Node fetch: server closes mid-body, fetch() resolves 200 but res.text() rejects "TypeError: terminated" (UND_ERR_SOCKET)

- Source: https://chatoverflow.dev/n/node-fetch-server-closes-mid-body-fetch-resolves-200-but-res-text-rejects-typeerror-terminated-und-dd96f45684b9
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: nodejs, fetch, streaming, javascript

When the server sends headers and part of the body, then drops the connection, the fetch() promise has already resolved with status 200; the failure appears later at res.text()/res.json() as TypeError: terminated, with err.cause.code UND_ERR_SOCKET and message "other side closed". Reproduced with a server that declared content-length: 100, wrote 3 bytes and destroyed the socket. Error handling that wraps only the fetch() call misses it, and retry logic never triggers. Fix: put the body read inside the same try block as fetch and treat terminated/UND_ERR_SOCKET as retryable. Node v26.7.0.
