Repository navigation
fix(viz): keep the server up when the browser opener is missing - #820
shu-chen-dot-ca wants to merge 1 commit into
Conversation
🌱 graft blast radiusNothing outside this diff depends on it. 2 areas changed; no indexed dependents at depth 2. Who knows this code — 2 people across 2 areas
Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no Test signal per changed area — 1 ✗ · 1 –Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
Summary
Fixes #819
On Linux without
xdg-open(WSL, minimal images),vizprinted its URL and then exited with status 1 onError: spawn xdg-open ENOENT.spawnreports a missing executable later, as an'error'event on the child. Nothing listened for it, so Node threw it and the server went down with the process.openBrowserhad the same gap: itstry/catchonly sees errors thrown whilespawnis called, not this later event.Changes
src/util/browser.ts:openBrowseradds a no-op'error'listener to the child beforeunref(). As before, the printed URL is the fallback.src/cli.ts:vizcallsopenBrowser(srv.url)instead of its own copy of the opener logic, and the unusedspawnimport goes. Because of that,viznow also respectsGRAFT_NO_BROWSER, like the sign-in flow already does.--no-openis unchanged.test/browser-opener.test.ts(new, Linux only, since macOS always hasopenand Windows goes through the shell). Both tests run with aPATHthat has noxdg-open:openBrowserin a child process and checks the process is still alive 500 ms later;vizfromsrc/cli.tsand checks the server is still running a second after it prints the URL, and that/api/context-graphanswers 200.Testing
On Ubuntu with Node 24.22:
PATHwithoutxdg-open:viz exited with status 1,spawn xdg-open ENOENT. With this branch the server stays up and serves the page (HTTP 200). Screenshots below.test/browser-opener.test.ts: 2/2 fail with main'ssrc/and 2/2 pass here.xdg-openstand-in still gets the URL;--no-openstill serves (200);GRAFT_NO_BROWSER=1no longer calls the opener.tsc -p tsconfig.json --noEmitis clean.npm test(TZ=UTC GRAFT_TEST_CONCURRENCY=4, with~/.trailand~/.graftcleared first): 4493 pass, 0 fail, 8 skipped.TZ=UTCmatches CI. In a US Eastern timezone,test/share-session.test.tsexpectsOct 1and getsSep 30, on main too.trail-scenario-hooks.test.tsand 1 inlesson-index-1b.test.ts. They failed on main as well, because of~/.trail/sessions/*.ship-checks.jsonand~/.trail/reposthat the first run had written. Clearing those fixed it.Screenshots