Skip to content

Survive a missing xdg-open during login - #3

Merged
ralyodio merged 2 commits into
mainfrom
fix/open-browser-spawn-error
Sep 4, 2026
Merged

Survive a missing xdg-open during login#3
ralyodio merged 2 commits into
mainfrom
fix/open-browser-spawn-error

Conversation

@ralyodio

@ralyodio ralyodio commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

What

`myna login x` (and every other OAuth 2.0 login) died on a headless server right after printing the authorize link and the "Paste the code you were shown" prompt. The trace ended in the runtime's `child_process` spawn.

`openBrowser` spawns `xdg-open` to raise a browser. When the binary is missing, `spawn` does not throw; it emits an asynchronous `error` event (ENOENT). Nothing listened for it, so the unhandled event took the process down on the next tick, after the prompt was already on screen. The `try/catch` around the spawn only ever covered a synchronous throw.

Fix

Attach an `error` handler to the child. The caller prints the link as well, so a failed opener costs nothing; the user pastes the code as before.

Test

`packages/core/test/open-browser.test.ts` empties `PATH`, calls `openBrowser`, and asserts no uncaught exception surfaces. It fails on `main` with the same ENOENT trace seen in the terminal and passes with the handler.

`bun test`: 132 pass, 0 fail. `bun run typecheck`: clean.

Where it bit

Adding a second X account over SSH on the dev box. The link printed, the process died, the pasted code was orphaned (its PKCE verifier died with the process), and `myna accounts` never showed the new handle.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HWRBUb6VUCM2xBmRk91FzG

ralyodio and others added 2 commits September 4, 2026 08:25
On a server with no desktop, spawn("xdg-open") reports ENOENT as an
asynchronous "error" event rather than throwing, so the try/catch in
openBrowser caught nothing and the unhandled event ended `myna login x`
a moment after it had printed the paste-the-code prompt. Attach an error
handler; the caller prints the link anyway, which is all the user needs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HWRBUb6VUCM2xBmRk91FzG
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HWRBUb6VUCM2xBmRk91FzG
@ralyodio
ralyodio merged commit 78d056c into main Sep 4, 2026
2 checks passed
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