Skip to content

browse: orphaned chrome-headless-shell processes leak CPU on CDP disconnect #294

Closed

Description

@eternalwaitt

Description

When the browse tool's CDP connection drops (e.g., after a hard navigation via window.location.href or a page that crashes during hydration), the tool prints [browse] Starting server... and spawns a new chrome-headless-shell process — but never kills the previous one.

After several retries, orphaned renderer processes accumulate. Each sits at ~120% CPU spinning on about:blank. In my case, 7 orphaned processes consumed ~840% CPU total, exhausting system resources and crashing my Next.js dev server.

Steps to reproduce

  1. Start a browse session and navigate to a page that triggers a hard redirect or heavy client-side hydration:
    $B goto http://localhost:3111/login
    $B fill @e2 "[email protected]"
    $B fill @e4 "password"
    $B click @e6   # triggers window.location.href = '/'
    
  2. The login succeeds, but the destination page's JS execution crashes the headless browser tab
  3. Any subsequent $B command prints [browse] Starting server... and spawns a new browser
  4. Repeat steps 1-3 — chromium processes accumulate

Observed behavior

Clicked @e6 → now at http://localhost:3111/login
[browse] Starting server...
about:blank

ps aux | grep chrome-headless-shell shows multiple renderer processes, each at ~120% CPU:

chrome-headless-shell --type=renderer ...  120.0%
chrome-headless-shell --type=renderer ...  121.9%
chrome-headless-shell --type=renderer ...  119.6%
chrome-headless-shell --type=renderer ...  143.1%
... (7 total)

Expected behavior

When [browse] Starting server... triggers, the tool should kill any existing chrome-headless-shell processes from previous sessions before spawning a new one. A PID file or process group tracking would prevent orphans.

Workaround

Manually kill orphaned processes:

pkill -f "chrome-headless-shell"

Environment

  • gstack version: 0.9.5.0
  • OS: macOS (Apple Silicon)
  • Playwright chromium: chromium_headless_shell-1208
  • Trigger: Next.js app with window.location.href redirect + heavy client-side hydration (next/dynamic SSR bailout)

Activity

  1. added a commit that references this issue on Mar 21, 2026
    919f1a7
  2. added a commit that references this issue on Mar 22, 2026
    cf3582c
  3. added a commit that references this issue on Mar 29, 2026
    b0d6578
  4. added a commit that references this issue on Mar 29, 2026
    8b80f1d
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