fix(http): Introduce a max buffer size for fetch requests on SSR#68927
Open
JeanMeche wants to merge 1 commit into
Open
fix(http): Introduce a max buffer size for fetch requests on SSR#68927JeanMeche wants to merge 1 commit into
JeanMeche wants to merge 1 commit into
Conversation
By default, the `FetchBackend` on SSR will limit the response body size to 10 MB. If the response body exceeds this limit, an error will be thrown. This default value can be configured by providing a different value for the `HTTP_FETCH_MAX_RESPONSE_SIZE` injection token. This is to prevent DoS on the server when loading large files
8a4443e to
6feec73
Compare
alan-agius4
reviewed
May 26, 2026
Contributor
alan-agius4
left a comment
There was a problem hiding this comment.
I wonder if we should consider adding a per-request configuration. If a developer needs to handle a single request larger than 10MB (which is already an edge case), modifying the global setting would inadvertently allow all requests to exceed that limit.
OOC, how did we we came up with a 10mb as a sensible default? IMO, 10mb is still rather large which can still easily cause a DoS.
| chunks.push(value); | ||
| receivedLength += value.length; | ||
|
|
||
| if (this.maxResponseSize !== null && receivedLength > this.maxResponseSize) { |
Contributor
There was a problem hiding this comment.
NIT if the content length header is provider and it's larger than the maxResponseSize we can skip this logic and get and open the reader.
| const req = new HttpRequest('GET', '/test', {responseType: 'text'}); | ||
| const events = await trackEvents(backend.handle(req)); | ||
|
|
||
| expect(events.length).toBe(2); |
Contributor
There was a problem hiding this comment.
NIT
Suggested change
| expect(events.length).toBe(2); | |
| expect(events).toHaveSize(2); |
| const events = await trackEvents(backend.handle(req)); | ||
| const error = events[1] as HttpErrorResponse; | ||
|
|
||
| expect(events.length).toBe(2); |
Contributor
There was a problem hiding this comment.
NIT
Suggested change
| expect(events.length).toBe(2); | |
| expect(events).toHaveSize(2); |
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.
By default, the
FetchBackendon SSR will limit the response body size to 10 MB. If the response body exceeds this limit, an error will be thrown.This default value can be configured by providing a different value for the
HTTP_FETCH_MAX_RESPONSE_SIZEinjection token.This is to prevent DoS on the server when loading large files