Repository navigation
fix(cli): normalize undefined cleanup exit codes - #8313
Closed
ShuaixinHuang wants to merge 2 commits into
Closed
ShuaixinHuang wants to merge 2 commits into
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. |
11 tasks done
Contributor
[Medium impact] The code appears safe to merge; no actionable issues were found. SummaryThe PR normalizes an omitted exit code to zero before cleanup. Cleanup or final output failures can then change it to one.
Reviews (1) · Last reviewed commit: "test(cli): cover omitted exit codes duri..." · Reviewed by Greptile |
2 tasks done
11 tasks done
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.
Supersedes #8246 at the author's explicit request to resubmit the current eight PRs. This replacement reuses the identical published head
68918691951bbc820a20ee5624d265f89f594de4and preserves the prior discussion and verification history at #8246 (earlier #8079). No code changes or new local test runs were made for this resubmission. This new PR must complete its own hosted CI; earlier same-head checks are historical evidence only. The owner has specifically confirmed review of this replacement PR's final diff, evidence and limitations, accepted full responsibility, and approved it for initial maintainer review.Supersedes #8079 at the author's request. This replacement reuses the same verified head commit and preserves the original discussion and validation record at #8079. Hosted CI for this new PR must complete independently.
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.