fix(http): cancel oversized fetch response bodies - #70210
Open
SkyZeroZx wants to merge 1 commit into
Open
Conversation
Cancel the unread response body before reporting NG02825 when its declared Content-Length exceeds the configured buffer limit. Without cancellation, SSR can finish while the underlying connection remains open. Add regression coverage for the declared-length rejection path.
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.
Cancel the unread response body before reporting NG02825 when its declared Content-Length exceeds the configured buffer limit. Without cancellation, SSR can finish while the underlying connection remains open.
What is the current behavior?
FetchBackendrejects a response when its declaredContent-Lengthexceeds the configured buffer limit. This happens before Angular creates a body reader, and the response body is not cancelled on this rejection path.In a local Angular 22.1.2 SSR application, five declared-length responses were rejected but all five connections remained open. The equivalent streamed-overrun case rejected all five responses and cancelled all five streams.
The smallest response used in the reproduction declared
Content-Length: 1048577, sent no body bytes, and kept the socket open. Eight SSR requests left eight outbound connections open after two seconds.Without cancellation, repeated requests can retain outbound connections after their Angular requests have already failed. The observed effect was socket and file-descriptor pressure rather than allocation of the declared response body.
A bounded availability test used one CPU, 256 MiB of memory, a healthy upstream with 250 ms latency, and approximately 192 open responses: