Skip to content

fix(browse): use detached child_process.spawn on Windows for server p…#444

Open
abdolrhman-mo wants to merge 1 commit intogarrytan:mainfrom
abdolrhman-mo:fix/windows-browse-server-persistence
Open

fix(browse): use detached child_process.spawn on Windows for server p…#444
abdolrhman-mo wants to merge 1 commit intogarrytan:mainfrom
abdolrhman-mo:fix/windows-browse-server-persistence

Conversation

@abdolrhman-mo
Copy link

Summary

  • Fix headless browser being completely non-functional on Windows
  • Server subprocess now persists between CLI invocations

Problem

On Windows, Bun.spawn() with proc.unref() 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 /browse, /qa, and /qa-only skills completely broken on Windows.

Symptoms:

  • Every command prints [browse] Starting server... (new server each time)
  • $B goto https://example.com then $B url returns about:blank
  • $B snapshot -i always returns "no accessible elements found"
  • No pages render — not Next.js specific, ALL websites fail

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.spawn with { detached: true, stdio: 'ignore' } instead of Bun.spawn. This creates a truly detached process that survives parent exit on Windows. Non-Windows platforms continue using Bun.spawn unchanged.

Testing

Tested on Windows 11 Enterprise (10.0.26200) with Next.js 16 + Turbopack:

Before fix:

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant