Skip to content

agent-browser fails to clean up headless Chrome processes, causing zombie processes that consume 100% CPU #17388

@zhengriu

Description

@zhengriu

Description

When hermes-agent launches agent-browser (headless Chrome) for a task, the Chrome child processes are not properly
cleaned up after the task completes. This leaves zombie Chrome processes running indefinitely, each consuming ~100%
CPU.

Environment

  • hermes-agent version: commit 24f139e (v0.11.0)
  • agent-browser version: 0.26.0
  • OS: macOS (Darwin 25.2.0, arm64)
  • Chrome version: 147.0.7727.102

Steps to Reproduce

  1. Run hermes gateway with an agent task that uses browser tool
  2. After the task completes, check running Chrome processes
  3. The headless Chrome processes remain running with high CPU usage

Observed Behavior

7 Chrome processes were left running for 3+ days after the original task completed, consuming a combined ~580% CPU:

┌─────────────────┬──────┬─────────────────┐
│ Process │ CPU% │ Total CPU Time │
├─────────────────┼──────┼─────────────────┤
│ GPU Helper │ ~99% │ 1663 min (~27h) │
├─────────────────┼──────┼─────────────────┤
│ Renderer (main) │ ~99% │ 5205 min (~86h) │
├─────────────────┼──────┼─────────────────┤
│ Renderer x3 │ ~97% │ ~1600 min each │
├─────────────────┼──────┼─────────────────┤
│ Network Helper │ ~95% │ 1616 min │
├─────────────────┼──────┼─────────────────┤
│ Storage Helper │ ~97% │ 1608 min │
└─────────────────┴──────┴─────────────────┘

Parent process was: agent-browser-darwin-arm64 (PID 92242), using user-data-dir:
/var/folders/gz/.../agent-browser-chrome-d5463250-...

The --headless=new --enable-unsafe-swiftshader Chrome instance was never terminated.

Expected Behavior

agent-browser should kill all spawned Chrome processes when the browser session ends or the parent process exits.

Suggested Fix

  • Add a process cleanup handler (e.g., atexit, signal handler) in agent-browser to ensure Chrome processes are
    terminated
  • Consider using process.kill(-pid) to kill the entire process group
  • Alternatively, track spawned Chrome PIDs and clean them up on session close

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existssweeper:implemented-on-mainSweeper: behavior already present on current maintool/browserBrowser automation (CDP, Playwright)type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions