fix(proxy): handle aborted upstream responses#101315
Merged
Merged
Conversation
Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
Contributor
Author
|
Land-ready proof for exact head
Known proof gaps: no live external broken-origin service was used; the tests exercise the same real Node socket lifecycle on loopback. No docs or changelog entry is required by the current gates. |
Contributor
Author
|
Merged via squash.
|
This was referenced Jul 7, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 7, 2026
Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
giodl73-repo
pushed a commit
to giodl73-repo/openclaw
that referenced
this pull request
Jul 8, 2026
Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #82442. The CONNECT client-socket crash reported there was fixed by #82444; this PR covers the distinct HTTP upstream-response stream failure path.
This is the clean maintainer replacement for #88052. GitHub could not reparent the contributor fork branch after fixups, so that PR began showing unrelated
mainfiles despite the reviewed two-file tree.What Problem This Solves
The debug proxy consumed upstream
IncomingMessagebodies without anerrorlistener. If an origin closed the connection after sending response headers, Node emitted a response-stream error that could become unhandled and crash the proxy.The old candidate handler also tried to end the downstream response with the upstream error text. Once a 2xx status and partial body had already been forwarded, that would make a truncated response look complete and append diagnostic text to application data.
Why This Change Was Made
502 Bad Gatewayresponse withConnection: close.This follows Node's documented HTTP lifecycle: a premature upstream close after the response begins emits
aborted/close/erroron the incoming response, while destroying an outgoing response closes its socket. See the Node HTTP documentation.User Impact
Broken origins no longer crash the local debug proxy. Failures before headers produce a truthful 502; failures after headers terminate the partial response; the proxy remains available for subsequent requests.
Evidence
5ef0700be070b6bc1b5bb01fcc562f6e1d1cc23c.run_246cffe1bd2b, leasecbx_71a6b7c8518f, Nodev24.15.0, public networking, no Tailscale, no instance profile.pnpm test src/proxy-capture/proxy-server.test.ts src/proxy-capture/proxy-server.managed-proxy.test.ts.The original contributor reproduction established the missing-listener crash surface. The maintainer rewrite preserves contributor credit and strengthens the client-visible contract and regression proof.
Original contributor PR: #88052.