Repository navigation
fix(cli): bound the OAuth browser open and say when it fails - #2499
Merged
Merged
Conversation
openUrl now races `open` against a 5s timeout, so a stalled opener on a headless box or container cannot hang the interactive OAuth flow. When the open fails or times out, the navigation writes a stderr line telling the user to open the already-printed URL by hand instead of swallowing the error silently. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
2 tasks done
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The behavior is correctly implemented and tested; only a non-blocking documentation correction remains.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds bounded CLI browser opening and a visible manual fallback for OAuth.
Changes:
- Adds a five-second timeout to
openUrl. - Reports browser-open failures to stderr.
- Documents and tests timeout/fallback behavior.
| File | Description |
|---|---|
clients/cli/src/open-url.ts |
Adds the browser-open timeout. |
clients/cli/src/cli-oauth-navigation.ts |
Prints manual-open guidance on failure. |
clients/cli/README.md |
Documents fallback behavior. |
clients/cli/__tests__/open-url.test.ts |
Tests rejection, timeout, and cleanup. |
clients/cli/__tests__/cli-oauth-navigation.test.ts |
Tests failure messages. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
Member
Author
|
Copilot round 1 — 1 finding (low), no suppressed comments.
|
Member
Author
|
Copilot round 2 — clean: no findings, no inline comments, no suppressed block. The round-1 finding is marked resolved. The review loop is closed (exit: first clean round). |
This was referenced Sep 26, 2026
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.

Closes #2410
What changed
clients/cli/src/open-url.ts:openUrlnow racesopen()against a timeout (OPEN_URL_TIMEOUT_MS, 5s).open10.x resolves as soon as it has launched the opener, but before that it probes the environment (WSL default browser, PowerShell path). On a headless box or in a container any of those can stall. The OAuth flow does not wait on this call (CallbackNavigationdiscards the promise), but without a timeout a stalled open never settles, so the fallback line below would never print. The timer is cleared on every path.clients/cli/src/cli-oauth-navigation.ts: the URL was already printed before the open, and a failure was swallowed silently. Now a failed or timed-out open writes one more stderr line:Could not open a browser automatically (<reason>). Open the URL above manually.The issue asked for a "print the URL as a fallback" path, and that already existed because the URL is always printed first. This change makes a failed open visible instead of looking like the flow is waiting on a browser.clients/cli/README.md: theMCP_AUTO_OPEN_ENABLEDrow now describes this behavior.Nothing changes when the open succeeds. The TUI has its own
openUrl(clients/tui/src/utils/openUrl.ts); it is out of scope because the issue is filed against the CLI.Tests
open-url.test.ts: a rejection propagates, a never-settling opener times out (fake timers), and the timer is cleared after a successful open.cli-oauth-navigation.test.ts: the old "swallows failures" case now asserts the exact fallback line. A new case covers a non-Errorrejection.npm run local:gatepassed locally. There is no UI change, so no screenshots.🤖 Generated with Claude Code