Skip to content

browse: Bun-compiled CLI cannot start server on Windows (process detection fails) #342

Closed

Description

@kwandoletcher

Summary

/browse is completely broken on Windows 11. The compiled browse.exe (Bun binary) cannot start or detect the browse server process, making all browse commands fail immediately with:

[browse] Another instance is starting the server, waiting...
[browse] Timed out waiting for another instance to start the server

This happens on fresh install with zero configuration. Every browse command fails, including browse --version.

Root Cause

The isProcessAlive() function in browse/src/cli.ts uses process.kill(pid, 0) to check if the server PID is alive. On Windows, Bun's compiled binary cannot reliably signal Windows-native process IDs this way. The call throws ESRCH even for running processes.

This causes a cascade failure in ensureServer():

  1. isProcessAlive(state.pid) returns false even when server is healthy
  2. Skips the HTTP health check entirely (line 240 guard)
  3. Falls through to lock acquisition, which also fails
  4. Prints "Another instance is starting the server" and times out

The server itself works fine. When started manually via node server-node.mjs, it launches Chromium, responds to health checks, and processes commands via HTTP. The bug is purely in the CLI's process detection.

Reproduction

  1. Install gstack on Windows 11
  2. Run any browse command: ~/.claude/skills/gstack/browse/dist/browse goto https://example.com
  3. Observe timeout error

Evidence

# Server starts fine manually:
$ BROWSE_STATE_FILE="$(pwd)/.gstack/browse.json" node ~/.claude/skills/gstack/browse/dist/server-node.mjs
[browse] Server running on http://127.0.0.1:33668 (PID: 19992)

# Health endpoint works:
$ curl http://127.0.0.1:33668/health
{"status":"healthy","uptime":3,"tabs":1,"currentUrl":"about:blank"}

# Commands work via direct HTTP:
$ curl -X POST http://127.0.0.1:33668/command -d '{"command":"goto","args":["https://example.com"]}'
Navigated to https://example.com (200)

# But browse.exe can't detect the running server:
$ browse goto https://example.com
[browse] Another instance is starting the server, waiting...
[browse] Timed out waiting for another instance to start the server

# Bun's process.kill fails for the Windows PID:
$ bun -e "process.kill(19992, 0)"  # ESRCH even though process is running

Suggested Fix

In ensureServer(), try the HTTP health check before (or regardless of) the PID alive check. The health check already exists but is gated behind isProcessAlive():

// Current (broken on Windows):
if (state && isProcessAlive(state.pid)) {
    // health check here - never reached on Windows
}

// Fix: try health check if state exists, regardless of PID signal
if (state) {
    try {
        const resp = await fetch(`http://127.0.0.1:${state.port}/health`, {
            signal: AbortSignal.timeout(2000),
        });
        if (resp.ok) {
            const health = await resp.json() as any;
            if (health.status === 'healthy') return state;
        }
    } catch {}
}

Same pattern should apply in the wait loop (line 273) and the under-lock re-check (line 282).

Environment

  • OS: Windows 11 Pro 10.0.26200
  • gstack: v0.9.8.0
  • Bun: 1.3.9
  • Node: v24.12.0
  • Shell: Git Bash (MSYS2)

Activity

  1. tan00 commented on Mar 23, 2026

    @tan00

    me too

  2. nwitthaus commented on Mar 23, 2026

    @nwitthaus

    I'm hitting a related but slightly different symptom on Windows 11 with gstack v0.11.5.2.

    My symptom: Instead of timing out, the CLI reports success (Navigated to https://example.com (200)) but the page never
    actually loads — url returns about:blank and html returns (39 chars). The
    server's Chromium crashes immediately after startup.

    How I found the root cause: Running the server in the foreground revealed the crash:

    $ export BROWSE_STATE_FILE="/.gstack/browse.json"
    $ node browse/dist/server-node.mjs

    [browse] Server running on http://127.0.0.1:48246 (PID: 13268)
    [browse] State file: .../.gstack/browse.json
    [browse] Idle timeout: 1800s
    [browse] FATAL: Chromium process crashed or was killed. Server exiting.

    Key evidence that Playwright itself is fine: Running this directly works perfectly — navigates, returns the full page
    title and content:

    node -e "
    const { chromium } = require('playwright');
    (async () => {
    const browser = await chromium.launch({ headless: true });
    const page = await (await browser.newContext()).newPage();
    await page.goto('https://example.com');
    console.log('Title:', await page.title());
    console.log('Content length:', (await page.content()).length);
    await browser.close();
    })();
    "
    // Output:
    // Title: Example Domain
    // Content length: 1256

    So the issue isn't Playwright or Chromium — it's how the Bun-compiled CLI spawns the Node server process. My theory:
    Bun.spawn() + proc.unref() on Windows doesn't truly detach the child process. When the Bun CLI exits, the Node server
    (and its Chromium grandchild) get killed as part of the process tree.

    What I see in the code (cli.ts:177-183):
    const proc = Bun.spawn(serverCmd, {
    stdio: ['ignore', 'pipe', 'pipe'],
    env: { ...process.env, BROWSE_STATE_FILE: config.stateFile },
    });
    proc.unref();

    The CLI writes the state file, confirms the PID is alive, then exits. By the time the next CLI invocation reads the
    state file and sends a command, Chromium has already crashed.

    Environment:

    • Windows 11 Pro (10.0.26200)
    • gstack v0.11.5.2
    • Bun 1.3.11
    • Node v24.1.0
    • Playwright 1.58.2
    • Shell: Git Bash
  3. added a commit that references this issue on Mar 24, 2026
    ee1c0c1
  4. added 2 commits that reference this issue on Mar 24, 2026
    3501f5d
    9461f05
  5. added a commit that references this issue on Mar 29, 2026
    3fb207b
  6. added a commit that references this issue on Mar 29, 2026
    b1a2915
  7. added a commit that references this issue on Apr 2, 2026
  8. added a commit that references this issue on May 30, 2026
    81edf6f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions