Repository navigation
fix(frontend): stream dynamic response compression - #6977
Merged
Merged
Conversation
Collaborator
Author
Helm Manifest DiffNo manifest changes detected across 17 application(s). |
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.
Dynamic response compression buffered each complete upstream body before returning it. Concurrent large API/SSR responses therefore retained additional complete buffers alongside the upstream payloads, creating a demonstrated memory amplification risk under the public frontend's 384 MiB limit.
Stream through Node's gzip/Brotli compressors with byte-bounded output buffering and backpressure. Pipeline teardown cancels the upstream source when the downstream reader disconnects and propagates source errors to the reader. Remove content-length on streamed compressed responses. Keep HEAD, SSE, already encoded, non-text, bodyless, and known-small responses unchanged. Unknown-length small bodies are now compressed without first buffering them to determine size.
Validation: 44 hook tests pass on Node 22.16.0, including gzip/Brotli round trips, returning before the whole upstream is consumed, cancellation, source errors, exclusions, and existing cache/privacy contracts. The two upstream-consumption tests fail against the original hook. A synthetic 32-concurrent-response probe using 3.4 MB payloads measured peak RSS of 336 MiB before and 276 MiB after on Node 22.16.0. This is a local memory-risk reproduction, not proof of the production OOM cause or production capacity.
No resource limits, budgets, credentials, or permissions changed. Full repository CI and live rollout verification remain pending; the coordinating thread owns merging. Both monolith and monolith-public use this frontend hook.