fix: stop swallowing failure exit codes#48
Merged
Conversation
…mand bodies `handleAsyncErrors` previously logged caught errors and let the process exit 0 — so a failed pull/push (401, network error, file-not-found) silently passed in CI. It now sets `process.exitCode = 1` on every caught error. Commands no longer call `process.exit` directly. Successful paths just return; failure paths log the user-facing message and throw a new `CliError`, which `handleAsyncErrors` translates to exit code 1 without re-printing. Tests no longer need the `ExitError` / `process.exit` spy workaround. - Add `CliError` for "we already printed a friendly message, just exit 1" - `handleAsyncErrors` always sets `process.exitCode = 1` on a caught error - Replace every `process.exit(0|1)` in commands and helpers with `return` or `throw new CliError(...)` - Add `handleAsyncErrors` unit tests covering the regression
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
handleAsyncErrorspreviously caught errors but never set a non-zero exit code — failed pulls/pushes silently passed in CI. It now always setsprocess.exitCode = 1on a caught error.CliErrorfor the "we've already printed a friendly user-facing message, just exit 1" case.handleAsyncErrorsrecognizes it and skips the generic error wrapper.process.exit(0|1)call from command bodies (pull,push,status) and helpers (getGlobalOptions,readFiles). Successful paths just return; failure paths log +throw new CliError(...).ExitError/process.exitspy workaround. Added 5 unit tests forhandleAsyncErrorscovering the regression.Test plan
pnpm build && pnpm test && pnpm lint && pnpm format:checkall passloco-cli statuswith no diff exits 0loco-cli statuswith a diff exits 1loco-cli pull/pushwith a missing/invalid access key exits 1 (and prints the access-key hint)loco-cli pullwithnat the prompt exits 0 (user declined ≠ error)loco-cli pushagainst a quota-capped project (Loco returns "Nothing updated") exits 1 with the explanatory message