Skip to content

fix: gracefully handle missing browser opener in headless environments#84

Closed
christso wants to merge 1 commit intonumman-ali:mainfrom
christso:fix/headless-browser-crash
Closed

fix: gracefully handle missing browser opener in headless environments#84
christso wants to merge 1 commit intonumman-ali:mainfrom
christso:fix/headless-browser-crash

Conversation

@christso
Copy link

Summary

  • Add commandExists() check before attempting to spawn browser opener
  • Prevents crash when xdg-open is not installed (Docker, WSL, CI, etc.)
  • The URL is still printed, so users can manually open it in their browser
  • Added tests for graceful handling when command is missing

Changes

File Description
lib/auth/browser.ts Added commandExists() helper that uses which/where to check if command exists before spawning
test/browser.test.ts Added 2 tests to verify graceful handling when opener command is missing

Test Results

All 211 tests pass:

 ✓ test/browser.test.ts (6 tests) 50ms
 Test Files  9 passed (9)
      Tests  211 passed (211)

Test Plan

  • Existing tests pass
  • New tests added for missing command scenario
  • Manually verified fix works by clearing PATH and calling openBrowserUrl()

Closes #83

🤖 Generated with Claude Code

- Add commandExists() check before attempting to spawn browser opener
- Prevents crash when xdg-open is not installed (Docker, WSL, CI, etc.)
- The URL is still printed, so users can manually open it
- Added tests for graceful handling when command is missing

Fixes numman-ali#83

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@numman-ali
Copy link
Owner

Closed by v4.3.0 (tag v4.3.0). Numman’s been busy, so I handled this on his behalf — thank you for your time and for the report. This was a tough job, but Sam Altman had my back getting it over the line.

Release: https://github.com/numman-ali/opencode-openai-codex-auth/releases/tag/v4.3.0
If you can, please follow and repost the release update on X: https://x.com/nummanali/status/2007975206711967764

@numman-ali numman-ali closed this Jan 5, 2026
@christso christso deleted the fix/headless-browser-crash branch January 15, 2026 23:11
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.

[BUG] Auth flow crashes when xdg-open is not installed in headless environments

2 participants

Comments