Skip to content

fix(auth): report Ctrl-C at the login paste prompt as a cancellation - #275

Draft
AmanVarshney01 wants to merge 2 commits into
mainfrom
fix/auth-login-ctrl-c-aborts
Draft

AmanVarshney01 wants to merge 2 commits into
mainfrom
fix/auth-login-ctrl-c-aborts

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Sep 21, 2026

Copy link
Copy Markdown
Member

Ctrl-C at the auth login "Paste the callback URL" prompt never becomes a SIGINT (readline holds the terminal in raw mode); readline rejects the question with its own AbortError. readPastedCallbackUrl treated every AbortError as "the browser callback won", so login finished with no tokens and settled as CLI.INTERNAL_ERROR ("Sign-in finished without producing a credential."), exit 1. Callers such as create-prisma recorded a cancelled sign-in as a technical failure.

The paste signal's own aborted state now decides: aborted means the login is over; otherwise it is the user's Ctrl-C and throws CLI.PROMPT_CANCELLED, which the engine already settles as exit 3 for Ctrl-C at its own prompts.

Note for callers: this exits 3, not 130. Branch on the code (CLI.PROMPT_CANCELLED / CLI.ABORTED), not the exit code.

Verified in a real pty with the built binary: before [CLI.INTERNAL_ERROR] exit 1, after [CLI.PROMPT_CANCELLED] exit 3. Lint, typecheck, cli tests and check:error-reference pass. Not covered: Windows/Linux ptys.

🤖 Generated with Claude Code

On a TTY, `auth login` races the browser's loopback callback against a
readline prompt for a pasted callback URL. readline holds the terminal in
raw mode, so Ctrl-C there never becomes a SIGINT the engine could record.
readline closes the interface and rejects the question with its own
AbortError while the login's paste signal is still live.

The prompt treated every AbortError as "the browser callback won the
race", so login resolved with no tokens and the run settled as
CLI.INTERNAL_ERROR ("Sign-in finished without producing a credential."),
exit 1. A user cancelling sign-in was reported as a CLI bug.

The paste signal's own `aborted` state now decides: aborted means the
login is over and prompting stops, as before. An AbortError with the
signal still live is the user's Ctrl-C and throws CLI.PROMPT_CANCELLED,
the code the engine already settles as a user cancellation (exit 3) for
Ctrl-C at its own raw-mode prompts. The loopback server and the readline
interface are still torn down by the existing finally blocks. The
browser-won path and the wrong-paste re-prompt are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/@prisma/cli@275
npx https://pkg.pr.new/@prisma/cli-engine@275

commit: 38ce3f0

Shorten the two comments in the paste prompt's abort handling, drop the
error-conventions paragraph and the parenthetical in the
CLI.PROMPT_CANCELLED reference entry, and keep only the two tests that
guard the change: Ctrl-C at the prompt cancels, and the browser callback
still wins while the prompt waits. The engine already tests that the
code exits 3.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant