gstack/browse
Garry Tan b66d8b35fe
fix(browse): resolveDisconnectCause crashes on persistent-context disconnect
`browser?.process()` in headed mode reaches a BrowserContext-owned Browser
stub whose `.process` is undefined (not a function). The optional-chain
`browser?.process()` does NOT short-circuit on undefined methods — only
on null/undefined receivers — so it evaluates to `undefined()` and throws
an unhandled rejection. The throw crashes the bun process, gbd respawns
it, the next tab close hits the same path, loop forever.

Reproducer (live in gbrowser amsterdam-v7 right now):

    [overlay] Local listener bound on 127.0.0.1:35300 (PID: 19445)
    [browse] Tab closed (id=1, remaining=0)
    [stderr] [overlay] FATAL unhandled rejection: browser?.process is
             not a function. (In 'browser?.process()', 'browser?.process'
             is undefined)
    [browse] Shutting down...
    ...respawn, same crash, repeat...

Fix: split the null case from the no-process case.
- null browser → 'crash' (preserves the existing contract pinned by the
  "null browser returns crash" test)
- truthy browser without callable .process → 'clean' (persistent contexts
  in headed mode; the user controls the lifecycle so the right default
  is exit 0 / gbd does not restart)
- truthy browser with callable .process → unchanged exit-code introspection

In headed mode we genuinely cannot distinguish "user pressed Cmd+Q or
closed all tabs" from "Chromium crashed" because Playwright doesn't
expose the underlying Chromium PID through a persistent context. The
tradeoff is: if Chromium genuinely crashes in headed mode we now exit 0
and don't auto-restart. That's preferable to the respawn loop, and the
user can re-launch manually if they want.

Test: added "clean: browser without .process method (persistent context)"
which would have caught this bug. All 21 browser-manager-unit tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 07:56:47 -07:00
..
bin feat: multi-agent support — gstack works on Codex, Gemini CLI, and Cursor (v0.9.0) (#226) 2026-03-19 18:20:50 -07:00
scripts fix: ngrok Windows build + close CI error-swallowing gap (v0.18.0.1) (#1024) 2026-04-16 13:49:04 -07:00
src fix(browse): resolveDisconnectCause crashes on persistent-context disconnect 2026-05-22 07:56:47 -07:00
test fix(browse): resolveDisconnectCause crashes on persistent-context disconnect 2026-05-22 07:56:47 -07:00
PLAN-snapshot-dropdown-interactive.md fix: snapshot -i auto-detects dropdown/popover interactive elements (#845) 2026-04-05 22:57:45 -07:00
SKILL.md v1.39.1.0 feat: EXIT PLAN MODE GATE for plan-mode review skills (#1512) 2026-05-15 08:13:20 -07:00
SKILL.md.tmpl v1.28.0.0 feat: browse --headed/--proxy/--navigate + gstack/llms.txt + webdriver-only stealth (#1363) 2026-05-07 20:14:59 -07:00