Keep browse daemons alive across separate CLI invocations on macOS#1140
Open
be-student wants to merge 1 commit intogarrytan:mainfrom
Open
Keep browse daemons alive across separate CLI invocations on macOS#1140be-student wants to merge 1 commit intogarrytan:mainfrom
be-student wants to merge 1 commit intogarrytan:mainfrom
Conversation
The browse CLI was starting a server that looked healthy during the first command, but the daemon and its Chromium children were still tied to the launching shell session. A follow-up invocation would miss the prior server, start from about:blank, and lose all persisted browse state. This keeps the server fully Bun-native on POSIX by using a detached Bun spawn instead of adding a new Node launch dependency, keeps headless daemons alive on SIGHUP, and replaces the weak helper-only regression test with a real multi-invocation lifecycle test against a local HTTP server. Constraint: The fix must work with Bun-built CLI binaries on macOS without adding dependencies Rejected: Keep using Bun.spawn(...).unref() without detached sessioning | daemon and Chromium still died after the launching shell exited Rejected: POSIX Node launcher | fixed the symptom locally but added an unnecessary Node runtime dependency Confidence: medium Scope-risk: moderate Reversibility: clean Directive: Detached launch behavior is part of browse state persistence; do not revert to parent-attached spawn without re-testing separate invocations Tested: bun test test/browse-cli-daemon.test.ts; bun run build; manual browse goto https://example.com then separate browse url reuse check Not-tested: Full /qa and /canary flows on macOS after prolonged idle periods
b4689d1 to
2090f3d
Compare
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.
Summary
Keep
browsedaemons alive across separate CLI invocations on macOS.Before this change, a first command like
browse goto https://example.comwould succeed,but the daemon and Chromium session could still die with the launching shell. A second
invocation would then start a fresh server from
about:blank, losing browse state.Root Cause
The POSIX launch path was not putting the Bun server and its Chromium children into a
proper detached session/process group. In practice on macOS, the launched browser session
could still die when the short-lived parent shell exited. Shell hangups (
SIGHUP) werealso not explicitly handled for the headless reuse case.
Fix
detached: trueSIGHUP, matching the headless reuse intentagainst a local HTTP server
Verification
bun test test/browse-cli-daemon.test.tsbun run buildbrowse goto https://example.combrowse urlhttps://example.com/instead of restarting atabout:blankNotes
I explicitly avoided adding a new POSIX
noderuntime dependency in the final structure.