fix(codex): cap app-server JSONL input per message - #8
Closed
cestercian wants to merge 2 commits into
Closed
cestercian wants to merge 2 commits into
cestercian wants to merge 2 commits into
Conversation
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.
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 free
to 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.
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_MESSAGESonly 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 viaTextEncoder, not UTF-16 code units. Overflow drops the buffer and fails the session withCodexAppServerTransportError(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)