Repository navigation
[PR] fix(proxy): preserve buffered data after CONNECT handshake - #6595
Merged
ranxianglei merged 1 commit intoNov 14, 2026
Merged
Conversation
Contributor
Author
|
(ai: openai/gpt-6-astra) Corrected the topic classification in this PR and #6594 to N (server-side miscellaneous), matching reference/triage.md; the code and validation are unchanged. |
This was referenced Nov 14, 2026
Owner
|
Superseded by #6677 (merged as Landed into master via the real merge commit The fix for #6594 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix. |
This was referenced Nov 18, 2026
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.
Fixes #6594
Problem
connectThroughProxy()reads the HTTP CONNECT response with adatalistener, which puts the socket in flowing mode. Removing the listener and callingunshift(rest)does not stop that flow. Bytes after the response header can be discarded before the Promise recipient attaches its consumer. Bytes arriving during a delayed handoff can also disappear.A real loopback proxy returning successful headers and a nine-byte binary greeting in the same write loses all nine bytes on current master. The real
setupMitmblind-tunnelupstream.pipe(clientSocket)path reproduces the same failure. This affects server-first traffic over a generic proxy tunnel; the reproduction does not assume ordinary client-first model TLS traffic always encounters this ordering.Change
Read the handshake through
readable/read()so the socket retains tunnel data until its owner attaches a reader. Remove only the handshake reader once headers are complete and preserve the existingunshiftof trailing bytes. Ordinarydataconsumers and the productionpiperesume normally, without caller-side manual resume or timing workarounds.Add real TCP regression coverage for complete and fragmented headers, immediate and delayed consumers, coalesced and subsequent bytes, and the actual blind-tunnel pipeline. Post-request echo traffic and HTTP 407 rejection remain controls. Each success case compares exact binary bytes including zero, CR/LF and non-ASCII byte values.
Validation
Pinned base:
e1f31ad9d5b47500362699a9867819b861c7de96(0.1.213), Node v24.22.1.setupMitm e2e: remote CONNECT policy (#77, #240)test: this environment'sos.networkInterfaces()throwsERR_SYSTEM_ERROR(uv_interface_addresses, Unknown system error 1). Running that same isolated test on unchanged master reproduces the identical failure. No test was skipped or changed to conceal it.npm run typecheck,npm run build, unused-export check, test-import guard andgit diff --check: pass. Full regression remains the hosted CI gate.All-state duplicate screening covered CONNECT payload/buffered/data loss,
unshift, tunnel greeting/lost and prior Afloat16 tunnel submissions. #6092 concerns IPv6 authorities, #6577 concerns EOF before a complete response, and #6583 concerns proxy CA trust. This change preserves bytes after a successful response and composes with both pending transport fixes.Topic N (server-side miscellaneous), cross-client; suggested labels
p1,scope/wiringas described in #6594.