[WRONG BRANCH] fix(combos): bound preflight retained chunks - #329
Conversation
|
✅ Deterministic PR hygiene checks passed. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏳ DRAFT
What to do
Its title has been prefixed with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b78b29c05c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (buffered.length >= COMBO_STREAM_PREFLIGHT_MAX_CHUNKS | ||
| || bufferedBytes + next.value.byteLength > COMBO_STREAM_PREFLIGHT_MAX_BYTES) { |
There was a problem hiding this comment.
Commit as soon as the chunk cap is reached
When the upstream delivers exactly 1,024 tiny chunks and then pauses, the 1,024th chunk is retained but the chunk-count boundary is not checked again before the next reader.read(). Preflight therefore waits indefinitely for a 1,025th chunk instead of committing and exposing the buffered stream to the client. Include buffered.length >= COMBO_STREAM_PREFLIGHT_MAX_CHUNKS in the post-feed commit condition, and cover a source that stalls immediately after the boundary.
Useful? React with 👍 / 👎.
Motivation
Uint8Array, allowing a malicious upstream to amplify allocations via many tiny chunks and cause an availability DoS.Description
COMBO_STREAM_PREFLIGHT_MAX_CHUNKS = 1024and treat either the byte cap or the chunk-count cap as a commit boundary.replayBufferedResponsewith the already-read unsliced next chunk so no extra copies are retained.tests/combo-stream-preflight.test.tsthat verifies preflight stops buffering before consuming an excessive tiny-chunk prefix and that the replayed response preserves the full byte stream.Testing
./node_modules/.bin/bun test tests/combo-stream-preflight.test.ts— passed (5 passed, 0 failed).bun run typecheck— succeeded.bun run privacy:scan— passed.bun run test(full suite) — the broader test run surfaced unrelated pre-existing Lab/timeout issues; testing was stopped after the focused combo preflight tests passed successfully.Codex Task