Repository navigation
fix(auth): don't crash when no browser can be opened - #393
Merged
Merged
Conversation
On a machine without a browser launcher (a VM, a container, a server over SSH) login printed "Opened browser" and then died with an unhandled 'error' event from spawning xdg-open, so the printed link could never be used. - openScreen now attaches an error listener to every launched process and reports whether it actually started (`opened`). - Login only prints "Opened browser" when it did; otherwise the link already on screen is the way in, and the callback keeps waiting.
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.
Problem
On a machine with no browser launcher (a VM, a container, a server over SSH),
capylogin printed✓ Opened browser for authenticationand then crashed:The
openpackage startsxdg-openand returns right away; the "not found" arrives a tick later as anerrorevent with no listener, which Node treats as fatal. The surroundingtry/catchhad already returned, so it never caught it. The printed login link was never usable.Fix
openScreenattaches an error listener to every process it starts and returnsopened: boolean(read frompid, which Node leaves unset when a spawn fails).✓ Opened browser for authenticationonly when the browser actually opened. Otherwise it prints nothing extra: the link is already on screen and the callback server keeps waiting.Verification
tests/ui/openScreen.test.tscover a missing launcher (failing exactly the way Node reports it), the app-window fallback, a launcher that throws, a launcher that starts, and suppressed mode.xdg-openon PATH: the old code crashes withUnhandled 'error' event; the fixed code returns{"via":"default-browser","opened":false}and the process keeps running.