Repository navigation
[PR] fix: cancel rejected continuation response bodies - #7171
Merged
ranxianglei merged 1 commit intoNov 20, 2026
Merged
ranxianglei merged 1 commit into
ranxianglei merged 1 commit into
Conversation
Release non-429 response bodies when the continuation is discarded. Keep cancellation asynchronous so an unfinished tee sibling cannot delay the existing null fallback; preserve successful streams and 429 readers.
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 #7170
Problem
A rejected continuation returns
nullto preserve the existing fallback, but its non-429 branch clears the fetch watchdog without consuming or canceling the upstream response body. A server that sends an error chunk and leaves the response open retains that transport connection with no remaining consumer.The real HTTP regression uses an undici Agent with one connection: on unchanged master, the next request never reaches the server and its 1,500 ms watchdog aborts. The server has received one request and its unfinished 503 response is still open.
Change
Cancel the discarded non-429 body after the existing throttle and timer cleanup. Fire-and-forget cancellation keeps the fallback responsive even if a transport rejects cancellation or a tee sibling never finishes. Successful continuation streams remain owned by their caller; 429 responses remain owned by the bounded reader that refines model-specific holds.
The fixed real HTTP test receives both requests, observes the old 503 response close, and reads the next response in full. The change applies to the shared continuation helper in plugin and proxy pass-through lanes, independently of compression mode. It does not change retry decisions, request bytes, model-facing text, configuration, kernel code or response framing.
Validation
Tested on bili 0.1.216, Node 24.22.1, base
548e396022b9391e28a3c9061560be297779b8e8(current master when checked).{requests: 1, rejectedResponseClosed: false}before cleanup.{requests: 2, rejectedResponseClosed: true}.git diff --checkpass.Prior work
Screened all 258 pre-existing fork heads: this module has one complete fork version and no discarded non-429 body cancellation. All 12 upstream module revisions (four rejection-branch variants) also lack it. #6630 changes compress-loop response ownership; #1072 preserves client aborts for successful spliced streams. Their actual diffs do not fix this rejection path.