Skip to content

fix(device): don't crash when no browser opener is installed - #265

Merged
riglar merged 1 commit into
devfrom
fix/browser-enoent-and-docs
Oct 26, 2026
Merged

riglar merged 1 commit into
devfrom
fix/browser-enoent-and-docs

Conversation

@riglar

@riglar riglar commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Fixes two comments on #260:

What & why

openBrowser crashed the CLI when no opener is installed

spawn doesn't throw when the program is missing. It emits an 'error' event, and with no listener that event crashes the process. So on a headless Linux box without xdg-open, dcd device open printed "Opened the monitor", then died with spawn xdg-open ENOENT and exit 1.

  • openBrowser now waits for 'spawn' or 'error', and returns false when the opener can't start. It is async now, and both callers (dcd login and dcd device open) await it.
  • Callers already handle false: they print the URL to open by hand, and exit 0.

Docs said the bridge remakes its connection on renewal

#261 changed this, but CLAUDE.md and the bridge.ts header still described the old behaviour. Both now say: one shared connection, with the auth re-read from getContext() on every request.

How to test

  • New test: startOpener with a program that doesn't exist returns false instead of crashing. It uses a made-up program name, so no test ever starts a real browser.
  • pnpm lint (0 errors), pnpm typecheck, pnpm test:unit (461 passing).

🤖 Generated with Claude Code

@claude

claude Bot commented Oct 26, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

Base automatically changed from feature/agent-devices to dev October 26, 2026 09:05
spawn reports a missing opener (xdg-open on a headless box) as an 'error' event, not a throw, and with no listener it crashed the process after dcd device open had printed "Opened the monitor". openBrowser now waits for 'spawn' or 'error' and returns false, so callers print the URL instead.

Also corrects CLAUDE.md and the bridge.ts header: the bridge keeps one connection and re-reads auth on every request; it no longer remakes the connection when a session is renewed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@riglar
riglar force-pushed the fix/browser-enoent-and-docs branch from 42fde10 to 8d05b45 Compare October 26, 2026 09:37
@riglar
riglar merged commit 2e566ef into dev Oct 26, 2026
9 checks passed
@riglar
riglar deleted the fix/browser-enoent-and-docs branch October 26, 2026 09:43
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