Skip to content

Comments

fix(cli): exit with non-zero code when it fails to start#7010

Merged
chenjiahan merged 2 commits intomainfrom
fix/cli-exit-code
Jan 22, 2026
Merged

fix(cli): exit with non-zero code when it fails to start#7010
chenjiahan merged 2 commits intomainfrom
fix/cli-exit-code

Conversation

@Timeless0911
Copy link
Contributor

Summary

Ensure the CLI process exits with a non-zero exit code (1) when it fails to start.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 22, 2026 08:22
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Timeless0911, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of the CLI by implementing a standard practice for error reporting. By ensuring the process terminates with a non-zero exit code upon failure, it provides a clear signal to calling environments, such as CI/CD pipelines or shell scripts, that an operation did not complete successfully. This change improves the overall reliability and diagnosability of CLI-based workflows.

Highlights

  • Error Handling: The CLI now explicitly exits with a non-zero status code (1) when an error occurs during its initialization or execution, ensuring that external scripts can reliably detect failures.
  • E2E Testing: A new end-to-end test case has been added to verify that the CLI correctly exits with status code 1 when provided with unknown command-line options, confirming the improved error handling.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Timeless0911 Timeless0911 changed the title fix(cli): exit with non-zero code on error fix(cli): exit with non-zero code when it fails to start Jan 22, 2026
chenjiahan
chenjiahan previously approved these changes Jan 22, 2026
Copy link
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@chenjiahan chenjiahan enabled auto-merge (squash) January 22, 2026 08:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds error handling to ensure the CLI exits with a non-zero exit code when it fails to start. Previously, when setupCommands() threw an error (e.g., due to an unknown option), the process would log the error but exit with code 0, making it difficult to detect failures in scripts or CI/CD pipelines.

Changes:

  • Added process.exit(1) to the error handler in runCLI() to ensure non-zero exit codes on failures
  • Added a test case to verify CLI exits with code 1 when unknown options are provided

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/cli/index.ts Added process.exit(1) in the error catch block to exit with non-zero code on CLI startup failures
e2e/cases/cli/unknown-option/src/index.js Created minimal entry point file for the unknown-option test case
e2e/cases/cli/unknown-option/index.test.ts Added test to verify CLI exits with error code 1 when unknown options are provided

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenjiahan chenjiahan disabled auto-merge January 22, 2026 08:26
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 22, 2026

Deploying rsbuild-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: ba75636
Status: ✅  Deploy successful!
Preview URL: https://ab0c52c3.rsbuild-v2.pages.dev
Branch Preview URL: https://fix-cli-exit-code.rsbuild-v2.pages.dev

View logs

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly ensures the CLI exits with a non-zero code on failure by adding process.exit(1) to the main error handling block. The accompanying e2e test is a great addition. I've suggested a small improvement to the test to make it more robust by ensuring it fails if the CLI command doesn't throw an error as expected.

Copy link
Contributor

Copilot AI commented Jan 22, 2026

@Timeless0911 I've opened a new pull request, #7012, to work on those changes. Once the pull request is ready, I'll request review from you.

@chenjiahan chenjiahan merged commit 44a330e into main Jan 22, 2026
6 checks passed
@chenjiahan chenjiahan deleted the fix/cli-exit-code branch January 22, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants