Skip to content

fix(codex): cap app-server JSONL input per message - #8

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

cestercian wants to merge 2 commits into
mainfrom
cursor/codex-appserver-message-byte-limit-1175

Conversation

@cestercian

Copy link
Copy Markdown
Owner

Summary

Codex app-server JSONL stdin had no per-message byte limit while fragments accumulate, so a huge provider line could blow memory before parse. MAX_BUFFERED_RAW_MESSAGES only caps decoded queue depth.

This adds a 128 MiB per-message / remainder ceiling checked as fragments arrive and before remainder.join() / parse. Retained text is measured as UTF-8 byte length via TextEncoder, not UTF-16 code units. Overflow drops the buffer and fails the session with CodexAppServerTransportError (read-input-stream), matching other stdin fail-closed paths.

Test plan

  • vp test run packages/effect-codex-app-server/src/protocol.test.ts (22 passed)
  • Regression: fragments crossing a tiny injected ceiling fail transport without dispatching notifications
  • Regression: a multibyte payload whose UTF-16 length is under the ceiling is still rejected when UTF-8 bytes exceed it
  • Existing ~4 MiB fragmented-diff case still passes under the production ceiling
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.
Retained JSONL fragments were sized with UTF-16 code units, so multibyte
input could exceed the 128 MiB ceiling. Measure with TextEncoder and
construct the transport error at each failure site.
@cestercian cestercian closed this Sep 21, 2026
@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
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