Repository navigation
fix: keep the host running when an RPC error response cannot be built - #315
Merged
Merged
Conversation
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This was referenced Nov 4, 2026
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.
Why
The advisor on #313 found three ways an RPC error response can still break, and the operator wants them shipped now:
RpcServerstarts each request withvoid this.processRequestLine(...). If building or sending the response throws, the rejection is unhandled. Node then ends the host process, and the session endsfailed.sendableDetailskeeps any JSON. AtoJSONcan turndetailsintoundefined, a string or an array.undefinedmakesserialized.lengththrow. A string or an array failsRpcResponseSchema, so the server's invariant throws. Both become the unhandled rejection in point 1.CliErrormessage of any length. A 1.1 MB message gives "RPC response exceeds maximum buffer size." at the CLI instead of the error's code.mainhas the same gap, forCliErrorand for other errors.What changed
src/host/rpcServer.ts:.catchonprocessRequestLinelogs the error withconsole.errorand answersRPC_ERROR"RPC request handling failed unexpectedly." with the request's id. The host keeps running.sendableDetailskeepsdetailsonly whenJSON.stringifygives a string of at most 65,536 characters that parses to a plain object.sendableMessagecuts an error message to 65,536 characters, ending with[message truncated]. BothRPC_ERRORresponses andCliErrorresponses use it.src/host/README.mddescribes the message cap and the unexpected-failure answer.Behavior changes for CLI and JSON users
[message truncated]. Before, the CLI reported exit 9RPC_ERROR"RPC response exceeds maximum buffer size.".RPC_ERROR"RPC request handling failed unexpectedly." Before, the host process crashed and the session endedfailed.The host's stdio is
'ignore', so theconsole.errorline shows only when the host runs in the foreground, for example in tests.Verification
test/unit/host/rpcServer.test.ts, a realRpcServerand the realsendRpcover a Unix socket.toJSONreturningundefined, a string or an array: test timeout, and Vitest reports the unhandled rejections (TypeError: Cannot read properties of undefined (reading 'length'), and twiceRPC CliError response must satisfy RpcResponseSchema.).messagegetter throws: test timeout and an unhandled rejection.CliErrormessage, and the same message on a plainError: "RPC response exceeds maximum buffer size.".detailscase passes on e7c7e1d and stays covered.vitest run test/unit/host/rpcServer.test.ts test/unit/host/rpcClient.test.ts: 26 passed.vitest run test/unit: 1949 passed.tsc --noEmit,oxlint src test vitest.config.tsandoxfmt --checkpass.Refs #313
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:xhigh