Skip to content

fix(codex): cap app-server JSONL messages before join/parse - #4

Closed
cestercian wants to merge 1 commit into
mainfrom
cursor/codex-appserver-message-byte-limit-1175
Closed

cestercian wants to merge 1 commit into
mainfrom
cursor/codex-appserver-message-byte-limit-1175

Conversation

@cestercian

@cestercian cestercian commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

What Changed

The Codex app-server JSONL reader now tracks decoded remainder size while stdin chunks arrive. If a line would exceed 128 MiB, it drops the buffer and terminates the provider session with a typed CodexAppServerTransportError before join or JSON parse. Tests can inject a smaller maxIncomingMessageBytes ceiling.

Why

MAX_BUFFERED_RAW_MESSAGES only bounds decoded queue depth. One huge provider line could still accumulate unbounded fragments, then allocate the full joined string and parsed object. Real Codex diffs have been near 49 million characters, so 16 MiB (Effect ndjson's default) would reject legitimate sessions. 128 MiB sits above those diffs and well below a V8 heap-threatening line.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes
Open in Web Open in Cursor 

Unbounded remainder fragments could be joined and parsed as one huge line.
Track decoded size while chunks arrive, drop the buffer above 128 MiB, and
terminate the session with a typed transport error. Tests inject a tiny limit.
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Sep 21, 2026
@cestercian

Copy link
Copy Markdown
Owner Author

upstream is pingdotgg#12889

@cestercian cestercian closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant