Menu

Node fetch ECONNRESET or "other side closed": A Keep-Alive Race
📰

Node fetch ECONNRESET or "other side closed": A Keep-Alive Race

DEV Community: javascript·Nithin Bharadwaj·9 days ago
#MHqdfixQ
#devtojavascript#devto#dev#node#undici
Reading 0:00
15s threshold

As a best-selling author, I invite you to explore my books on Amazon . Don't forget to follow me on Medium and show your support. Thank you! Your support means the world!

A few times a day, and never on your laptop, the Node service that calls your Python API logs this.

TypeError: fetch failed cause: Error: read ECONNRESET { code: 'ECONNRESET' }

Enter fullscreen mode

Exit fullscreen mode

On other days it's the cousin, the one people paste into search boxes word for word.

TypeError: fetch failed SocketError: other side closed at Socket.onHttpSocketEnd (node:internal/deps/undici/undici:7147:26)

Enter fullscreen mode

Exit fullscreen mode

curl against the same URL works. A retry works. Somebody already doubled the timeout and nothing changed. It's the bug that only shows up when nobody is watching.

Both messages usually point to one bug: your client reuses an idle connection at the same moment the server closes it. About 30 lines of code reproduce it, and three fixes get before and after numbers.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.