Skip to content

fix(fetch): do not crash on a late request-socket error - #42110

Closed
Lazizbek Ergashev (lazerg) wants to merge 1 commit into
microsoft:mainfrom
lazerg:fix-42074
Closed

fix(fetch): do not crash on a late request-socket error#42110
Lazizbek Ergashev (lazerg) wants to merge 1 commit into
microsoft:mainfrom
lazerg:fix-42074

Conversation

@lazerg

Copy link
Copy Markdown

Summary

  • When a server sends its response and then resets the connection without reading the request body (as workerd does when it refuses an oversized or rate-limited upload before consuming it), Node completes the response and detaches the request from its socket. The still-pending write of the unread body then errors on that socket, and with nothing listening for it the process exits with an unhandled write ECONNRESET that a try/catch around the call never sees.
  • Keep an error listener on the request socket so this late error no longer reaches the process. The response is already in hand by then, so the request resolves with it (or rejects through the normal request-failure path) instead of taking down the whole process.

Fixes#42074

@yury-s

Copy link
Copy Markdown
Member

See #42116

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: APIRequestContext kills the process on an unhandled request-socket ECONNRESET when a server refuses a body before reading it

2 participants

@lazerg@yury-s