fix(browse): use detached child_process.spawn on Windows for server p…#444
Open
abdolrhman-mo wants to merge 1 commit intogarrytan:mainfrom
Open
fix(browse): use detached child_process.spawn on Windows for server p…#444abdolrhman-mo wants to merge 1 commit intogarrytan:mainfrom
abdolrhman-mo wants to merge 1 commit intogarrytan:mainfrom
Conversation
…ersistence
Bun.spawn() with proc.unref() on Windows doesn't truly detach the server
subprocess — it dies when the CLI parent exits. This caused every $B command
to start a fresh Chromium instance at about:blank, making the browse binary
completely non-functional on Windows.
Fix: On Windows, use Node's child_process.spawn with { detached: true,
stdio: 'ignore' } which creates a truly independent process that survives
parent exit.
Tested on Windows 11 with Next.js 16 + Turbopack:
- Server persists between commands (no more "[browse] Starting server..." on every call)
- Pages render with full interactive elements
- goto + url returns the correct URL instead of about:blank
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Problem
On Windows,
Bun.spawn()withproc.unref()doesn't truly detach the server subprocess — it dies when the CLI parent exits. This caused every$Bcommand to start a fresh Chromium instance atabout:blank, making/browse,/qa, and/qa-onlyskills completely broken on Windows.Symptoms:
[browse] Starting server...(new server each time)$B goto https://example.comthen$B urlreturnsabout:blank$B snapshot -ialways returns "no accessible elements found"Root Cause
Bun.spawn+proc.unref()on Windows doesn't create a truly independent background process. When the CLI binary exits after sending a command, the child server process is killed by the OS.The code already handles a similar Windows-specific Bun limitation (oven-sh/bun#4253, #9911) by falling back to Node.js for the server. But the spawn mechanism itself was still using
Bun.spawn.Fix
On Windows, use Node's
child_process.spawnwith{ detached: true, stdio: 'ignore' }instead ofBun.spawn. This creates a truly detached process that survives parent exit on Windows. Non-Windows platforms continue usingBun.spawnunchanged.Testing
Tested on Windows 11 Enterprise (10.0.26200) with Next.js 16 + Turbopack:
Before fix: