Skip to content

[WRONG BRANCH] fix(combos): bound preflight retained chunks - #329

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-combo-sse-memory-dos
Draft

[WRONG BRANCH] fix(combos): bound preflight retained chunks#329
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-combo-sse-memory-dos

Conversation

@luvs01

@luvs01 luvs01 commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The combo SSE preflight path buffered every upstream read as a separate Uint8Array, allowing a malicious upstream to amplify allocations via many tiny chunks and cause an availability DoS.
  • The intent is to limit retained memory and allocation count while preserving the ability to commit and replay an already-read prefix for safe failover.

Description

  • Add a per-chunk cap COMBO_STREAM_PREFLIGHT_MAX_CHUNKS = 1024 and treat either the byte cap or the chunk-count cap as a commit boundary.
  • When a cap is hit, commit the current combo target and call replayBufferedResponse with the already-read unsliced next chunk so no extra copies are retained.
  • Update the preflight comment to reflect the dual cap and preserve existing replay semantics.
  • Add a focused regression test in tests/combo-stream-preflight.test.ts that 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

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 25, 2026
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c7ef68f8-e311-420b-825d-1d4a3a055998


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot changed the title fix(combos): bound preflight retained chunks [WRONG BRANCH] fix(combos): bound preflight retained chunks Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 25, 2026 04:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +145 to +146
if (buffered.length >= COMBO_STREAM_PREFLIGHT_MAX_CHUNKS
|| bufferedBytes + next.value.byteLength > COMBO_STREAM_PREFLIGHT_MAX_BYTES) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant