Repository navigation
[PR] fix: cancel discarded compress-loop response bodies - #6630
Merged
ranxianglei merged 1 commit intoNov 14, 2026
Merged
Conversation
This was referenced Nov 14, 2026
Owner
|
Superseded by #6677 (merged as Landed into master via the real merge commit The fix for #6628 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 #6628
Problem
The compression loop owns every initial, retry, and continuation response, but currently only clears its fetch timers. Adapters release their readers when parsing exits, leaving an unread response body open.
This happens without a client disconnect: an upstream can send an in-band OpenAI error and keep its HTTP response open. The loop successfully retries the logical request, yet the discarded first response stays alive. Returning after a visible chunk also leaves the initial or continuation response open. Real loopback HTTP tests reproduce all three cases on the base.
Change
Cancel the current response body after each parse attempt exits, before any retry replaces it. Also cancel in the outer
finallyso consumer return and parser exceptions release the current response.Cancellation is best effort and is not awaited: a raw-recording tee may still own its other branch, which must remain independently readable. Closed streams already have no unread work; the normal-completion control confirms that their underlying cancel callback is not invoked. Cleanup rejection does not replace the caller's result or the original parsing error.
The two ownership points add no per-event generator layer and leave adapter parsing, logical request bytes, retry eligibility, signed payloads, and tool execution unchanged.
Validation
acp_statuscontinuation. The retry still sends the same logical request and delivers its recovered answer.git diff --checkpass.The Codex prerequisite check finds the installed CLI and built artifact, but the configured real upstream at
127.0.0.1:8199is unreachable. The gated live four-phase suite was not run. The HTTP tests above use a real local upstream with the production loop; full repository regression remains hosted CI's responsibility.Prior work
All-state repository and author-history searches distinguish this ownership gap from #6051 (raw pipe paths) and #6571 (the inline fetch bridge). Neither changes
runCompressLoop, and the new in-band-error reproduction does not require client cancellation. This PR changes only the loop's ownership of response bodies it has finished using.