Skip to content

fix(frontend): stream dynamic response compression - #6977

Merged
jomcgi merged 1 commit into
mainfrom
fix/frontend-stream-compression
Oct 16, 2026
Merged

jomcgi merged 1 commit into
mainfrom
fix/frontend-stream-compression

Conversation

@jomcgi

@jomcgi jomcgi commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

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.

@jomcgi

jomcgi commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Helm Manifest Diff

No manifest changes detected across 17 application(s).

@jomcgi
jomcgi marked this pull request as ready for review October 16, 2026 05:20
@jomcgi
jomcgi added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit d2305c2 Oct 16, 2026
6 checks passed
@jomcgi
jomcgi deleted the fix/frontend-stream-compression branch October 16, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant