Skip to content

[Bug] /auth: "cancelled by user" error in Ghostty terminal #24745

@sehoon38

Description

@sehoon38

Description

When using the /auth command in the Ghostty terminal, the CLI prematurely reports "cancelled by user" during the OAuth flow, preventing successful sign-in.

Steps to Reproduce

  1. Open Ghostty.
  2. Run gemini-cli /auth.
  3. Select Option 1 (Login with Google).
  4. Consent prompt appears; select "Yes".
  5. Browser opens successfully for sign-in.
  6. Before/during sign-in completion, the CLI reports "cancelled by user".

Technical Investigation

The issue appears to originate from the cancellationPromise in gemini-cli/packages/core/src/code_assist/oauth2.ts. This promise listens for SIGINT or 0x03 (Ctrl+C) in process.stdin.

In Ghostty, it's possible that:

  • A SIGINT is triggered unexpectedly.
  • Ghostty sends a sequence that is interpreted as 0x03 in process.stdin.

Relevant code snippet:

    const cancellationPromise = new Promise<never>((_, reject) => {
      sigIntHandler = () =>
        reject(new FatalCancellationError('Authentication cancelled by user.'));
      process.on('SIGINT', sigIntHandler);

      // Note that SIGINT might not get raised on Ctrl+C in raw mode
      // so we also need to look for Ctrl+C directly in stdin.
      stdinHandler = (data: Buffer) => {
        if (data.includes(0x03)) {
          reject(
            new FatalCancellationError('Authentication cancelled by user.'),
          );
        }
      };
      process.stdin.on('data', stdinHandler);
    });

Metadata

Metadata

Assignees

Labels

area/platformIssues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmtarea/securityIssues related to securityhelp wantedWe will accept PRs from all issues marked as "help wanted". Thanks for your support!priority/p2Important but can be addressed in a future release.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions