Uh oh!
There was an error while loading. Please reload this page.
fix(llm): reject Bedrock event-stream frames above the 16 MiB maximum - #44631
Open
pacocartones wants to merge 1 commit into
Open
fix(llm): reject Bedrock event-stream frames above the 16 MiB maximum#44631pacocartones wants to merge 1 commit into
pacocartones wants to merge 1 commit into
Conversation
This was referenced Aug 24, 2026
renekris added a commit
to renekris/opencode-lowmem
that referenced
this pull request
Aug 26, 2026
- pin note, seam-lookup range, and deferred-port re-verification now reference v1.18.23 (post-split packages/ai|util tree still absent, anomalyco#43769 stays blocked) - watch-list gains the 2026-08-26 sweep candidates (anomalyco#39930, anomalyco#38939, anomalyco#41950, anomalyco#33713, anomalyco#44631) - fork-build.sh BASE lookup now excludes *-lowmem.* tags: after a fresh upstream merge the previous fork tag ties the new base tag on commit distance with a newer date and git describe stamps the OLD base
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 freeto 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.
Issue for this PR
Closes#44630
Type of change
What does this PR do?
bedrock-event-stream.tsreadstotal_lengthfrom the frame prelude and waits for that many bytes. It's a 32-bit field, so a malformed response can declare up to 4 GiB. Nothing bounds the wait, and since the buffer is only compacted once a frame completes,appendChunkre-copies the whole accumulated window on every network chunk — cost is quadratic in bytes received. Measured with 16 KiB chunks after a0xFFFFFFFFprelude: 16 MiB sent → 4.1 s / 166 MiB RSS; 64 MiB sent → 47.2 s / 650 MiB RSS. The stream then fails with the genericended without a terminal finish event, so there's no diagnostic either.AWS caps an event-stream message at 16 MiB.
@smithy/eventstream-codecdoesn't enforce it. This adds that check before the length gate, so an oversized prelude fails fast with the declared size in the message instead of buffering toward a frame that can never complete. Well-formed frames are unaffected — the check only fires above 16 MiB, which no valid Converse frame reaches.How did you verify your code works?
Added a test to
packages/llm/test/provider/bedrock-converse.test.tsthat feeds a prelude declaring0xFFFFFFFFthroughLLMClient.generateand asserts the framing error. Without the fix it fails withProvider stream ended without a terminal finish event; with it, it passes.bun testinpackages/llm: 298 pass ondev, 299 pass with this change, 0 fail.bun run typecheckclean.Screenshots / recordings
Not a UI change.
Checklist