Repository navigation
fix(cli): normalize undefined cleanup exit codes - #8079
ShuaixinHuang wants to merge 2 commits into
Conversation
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 usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; the fix addresses the reported failure and adds the previously requested tests. SummaryThe dispatcher treats an omitted exit code as
Reviews (2) · Last reviewed commit: "test(cli): cover omitted exit codes duri..." · Reviewed by Greptile |
Superseded by #8246 at the author's request: #8246 . The replacement uses the same head commit; this PR retains the original discussion and validation record.
Summary
Fixes #8049. The CLI dispatcher can receive an omitted exit code from
serve. If JavaScript worker cleanup then fails,let status = codeleavesstatusundefined; the cleanup branch only changes status when it equals numeric0, andprocess.exit(undefined)exits successfully. This hides a cleanup failure from shells and CI.Problem and expected behavior
When
exit(undefined)is followed by a cleanup or SDK-output finalization failure, the process must return a non-zero status. A defined numeric exit code keeps its existing value, while an omitted code is normalized to the normal success baseline before failure handling.Change and scope
Normalize the callback code with
typeof code === "number" ? code : 0before the existing cleanup/error handling. This is one line inscripts/rea.mjs; no worker ownership, output protocol, or cleanup ordering changes.Evidence and regression coverage
exit(undefined)bypasses bothstatus === 0checks and reachesprocess.exit(undefined), which reports success.1for an omitted code while preserving explicit numeric codes.node --check scripts/rea.mjspassed.npm run check:fast: dependency check, typecheck and lint passed 2/2.The reported failure was reproduced from the dispatcher control flow; no external provider or platform-specific runtime is required for this change.
Exit-code review regression
Follow-up
68918691951bbc820a20ee5624d265f89f594de4expands the existing executable dispatcher shutdown cases without changing production code. They cover omitted and explicit undefined exit codes during cleanup and final output failure, successful omitted-code finalization, and preservation of explicit status 7; the existing explicit-zero and closed-pipe cases remain.Windows, Node 24.22.1 / npm 11.16.0: the complete dispatcher file passes 21/21 with three build tasks successful. Temporarily reverting only the original one-line normalization makes 4 fail / 17 pass: omitted/undefined cleanup and output failures incorrectly exit 0. The production script was restored byte-for-byte afterward. Normal precommit passed and retained identical tested file bytes; check:fast passed 2/2. These are real child-process invocations of the production executable dispatcher with synthetic cleanup/output producers, not a real external analysis provider or MCP session. The new head needs its own hosted CI.
Author readiness
Human owner: @ShuaixinHuang
Before merge
type(scope): outcome.