Skip to content

fix(change): exit cleanly when an interactive prompt is canceled - #13817

Merged
zkochan merged 3 commits into
pnpm:mainfrom
lazerg:fix/issue-13814-change-prompt-cancel
Aug 17, 2026
Merged

zkochan merged 3 commits into
pnpm:mainfrom
lazerg:fix/issue-13814-change-prompt-cancel

Conversation

@lazerg

@lazerg lazerg commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #13814.

Ctrl-c out of a pnpm change prompt and the ExitPromptError that @inquirer/prompts throws travels all the way to the top-level handler, so backing out of the command ends in an error line plus a stack trace through pnpm's own internals. Every other interactive command already catches that error name at its prompt: update, audit --fix, approve-builds, patch remove, login, publish.

change now does the same, following what update does with it: print Change canceled and exit 0. The catch sits around recordChange, which covers all four prompts it can stop at (the package picker, the two bump pickers, the summary input). pnpm change status never prompts, so it stays outside the catch.

The Rust port needs nothing here. dialoguer reads keys through console's read_key, which re-raises SIGINT on Ctrl-c, so pacquet's pnpm change already ends quietly.

Squash Commit Body

Canceling any of the prompts of `pnpm change` let the ExitPromptError
that @inquirer/prompts throws reach the top-level error handler, which
printed it as a failure with a stack trace. Every other interactive
command catches that error name at its prompt.

Handle it the way `update` does: report the cancellation and exit with a
success status. The catch wraps recordChange, so it covers the package
picker, both bump pickers and the summary input; `change status` does
not prompt and stays outside it.

The Rust port is unaffected: dialoguer reads keys through console's
read_key, which re-raises SIGINT on Ctrl-c.

Closes pnpm/pnpm#13814.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Canceling the interactive change prompt with Ctrl-C now displays “Change canceled” and exits successfully.
    • Prevented an unnecessary stack trace from appearing when the prompt is canceled.
    • Other prompt errors continue to be reported normally.
  • Tests

    • Added coverage for cancellation during package selection, version bump selection, and summary entry.
    • Added verification that prompt failures unrelated to cancellation are still surfaced.

@lazerg
lazerg requested a review from zkochan as a code owner August 11, 2026 08:14
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The pnpm change command now handles Ctrl-C cancellation as a successful exit. It logs Change canceled instead of printing a stack trace. Tests cover cancellation at each prompt stage and non-cancellation errors. A changeset documents the patch releases.

Changes

Change prompt cancellation

Layer / File(s) Summary
Handle prompt cancellation
pnpm11/releasing/commands/src/change/index.ts
The command catches ExitPromptError, logs Change canceled, exits with status 0, and rethrows other errors.
Validate cancellation behavior
pnpm11/releasing/commands/test/change/cancel.test.ts, .changeset/change-prompt-cancel.md
Tests cover cancellation during package, bump, and summary prompts. They also verify that other errors are rethrown. The changeset documents the updated behavior and patch releases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Handle Ctrl-C with a softer close, show a cancellation message, and avoid a stack trace [#13814] ✅

Possibly related PRs

  • pnpm/pnpm#13207: Modifies the same change command and its tests for release-plan probing.
  • pnpm/pnpm#13428: Covers interactive prompt cancellation and successful process.exit(0) handling.
  • pnpm/pnpm#13818: Modifies the same command's interactive picker behavior for terminal page sizing.

Suggested labels: product: pnpm@11

Suggested reviewers: zkochan

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (2): Last reviewed commit: "test(change): cover every prompt that ca..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/releasing/commands/test/change/cancel.test.ts`:
- Around line 41-65: Expand the cancellation tests around the change handler to
cover both bump-selection checkbox prompts and the summary input, asserting
globalInfo receives exactly “Change canceled” and process.exit is called with 0.
Add a separate case verifying non-ExitPromptError failures are rethrown
unchanged, while preserving the existing package-selection coverage, and run the
focused Jest test for this file.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d37546c-9f84-473e-875a-3b414431bfaa

📥 Commits

Reviewing files that changed from the base of the PR and between 1c42ae2 and 93202ab.

📒 Files selected for processing (3)
  • .changeset/change-prompt-cancel.md
  • pnpm11/releasing/commands/src/change/index.ts
  • pnpm11/releasing/commands/test/change/cancel.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/releasing/commands/test/change/cancel.test.ts`:
- Around line 49-53: Update exitPromptError and the cancellation tests to
construct ExitPromptError from a separate node:vm context, ensuring cross-realm
native errors are covered rather than relying on instanceof Error. Extend the
expectExit() assertions to verify the cancellation output contains “Change
canceled” in addition to process.exit(0).
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4344dbc4-f57f-4520-99c9-6c1e28f3d4c4

📥 Commits

Reviewing files that changed from the base of the PR and between 93202ab and 474d6ef.

📒 Files selected for processing (2)
  • pnpm11/releasing/commands/src/change/index.ts
  • pnpm11/releasing/commands/test/change/cancel.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm11/releasing/commands/src/change/index.ts

@Netail Netail mentioned this pull request Aug 11, 2026
2 tasks done
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 11, 2026
@zkochan
zkochan merged commit ac0157b into pnpm:main Aug 17, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[pnpm change] hard close

2 participants