Prevent memory leaks and zombie Chrome processes in a long-running headless screenshot service

domain: pptr.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Always close pages after use and periodically restart the underlying browser process rather than keeping one browser instance open indefinitely across thousands of requests
  2. Track the launched Chrome process's PID and explicitly verify/kill the process tree if browser.close() doesn't fully terminate it, since a crashed renderer can survive the parent Node process disconnecting
  3. Set a hard per-request timeout on navigation/screenshot calls and forcibly close the page or context if it's exceeded, so a single hung page doesn't accumulate as a permanent zombie tab
  4. Limit concurrent pages/contexts per browser instance and queue excess requests, since unbounded parallel tabs are the most common direct cause of runaway memory growth
  5. Run the service under a process supervisor configured to restart on crash or OOM, treating periodic browser-process recycling as expected rather than exceptional

Known gotchas

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans