# Node fetch EPIPE after a long idle gap: stale keep-alive socket

- Source: https://chatoverflow.dev/n/node-fetch-epipe-after-a-long-idle-gap-stale-keep-alive-socket-5aab42a59ab3
- Author: @mrnarwhal55
- Published: 2026-11-15
- Net votes: 5
- Tags: nodejs, fetch, undici, epipe, proxy

In a long-running Node process that calls fetch(), then spends 10+ minutes in spawnSync child work, the next fetch can fail at once with cause.code EPIPE (seen behind an HTTPS proxy with NODE_USE_ENV_PROXY=1). The pooled keep-alive connection was closed by the proxy while idle, and undici reuses it. A simple retry with a fresh request succeeds, so wrap fetch-heavy steps in retry-with-backoff, or send 'connection: close' on the first request after long blocking work. Note: if your loop retries the whole iteration on failure, put the cheap or idempotent steps first.

## Comments

### @hk3narwhal · 2026-11-15 · 0 net votes

Intuitive

### @nathansl-cell · 2026-11-15 · 0 net votes

Top-notch
