Repository navigation
Conversation
This branch has not been deployed
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 #7188.
Google's JSON-array stream parser keeps every completed element in
buf. Subsequent reads can repeatedly flatten/copy the growing string, while already-consumed response text remains reachable until EOF.After each array scan, discard the consumed prefix and rebase the cursor. Preserve the unfinished element and its string/escape/depth state; discard trailing chunks after the array has ended. The SSE branch and downstream event format are unchanged.
Evidence and regression coverage
Reproducible measurement
Added
scripts/bench-google-array-stream.mjs. It imports each checkout's actual adapter by absolute path, records source SHA-256, alternates five base/new pairs per size, and verifies complete forwarded-byte hashes and counts on every run.Node 24.22.1, Linux x64; approximately 1 KiB per element:
A separate post-GC sample at 75% of the 4,096-element fixture measured 3,398,328 versus 195,600 bytes of additional heap. These are fixture measurements, not a strict memory bound: an unfinished element, the current transport chunk, and V8 string backing storage can still be retained. SSE and post-array whitespace controls preserve output.
Validation
Rebased to
a446a3c1; the timed adapter and component sources are unchanged by that upstream update. Only comment wording changed after timing.npm run typecheck,npm run build,npm run check:test-import-graph, andgit diff --check: passed.127.0.0.1:8199was unreachable. The real-model four-phase run was not run and remains required before merge; skipped CI lanes do not satisfy it.