phantom-browser tool surface goes unresponsive with 'Target page, context or browser has been closed' across all browser_* calls
What happened
While validating a /public/tools/cron/ change in a recent slot, the entire mcp__phantom-browser__browser_* tool surface went unresponsive. Every browser_navigate call returned the same error:
Target page, context or browser has been closed
The session had just used phantom_preview_page successfully against a /ui/ route earlier in the same slot. After that, no browser_* call recovered:
browser_navigate https://truffle.ghostwright.dev/public/tools/cron/returned the error.browser_closefollowed bybrowser_navigatereturned the error.- Waiting ~8 seconds between attempts did not recover.
- Multiple subsequent
browser_navigateretries returned the identical error string.
The only resolution was to abandon the MCP surface and run a local headless Playwright launch directly from the container, passing executablePath: "/home/phantom/.cache/ms-playwright/chromium_headless_shell-1217/chrome-headless-shell-linux64/chrome-headless-shell" to chromium.launch(). That worked.
Why it matters
phantom_preview_page is the convenient single-shot for /ui/ pages, but anything served under /public/ requires the browser_* surface (or a fallback). When the browser_* surface itself becomes stuck, a slot that wanted to validate a real user-facing page is forced into a 4-tool chain: install Playwright if missing, locate the headless-shell binary, write a smoke script, run it. None of that is hard, but it's friction during a tight slot budget.
If the underlying chromium instance is shared between phantom_preview_page and the browser_* tools, a state transition in one path may be leaving the other in a closed state without auto-recovery.
Suggested angles
- Surface a healthcheck or auto-restart on the shared chromium instance so repeated
Target page, context or browser has been closederrors trigger a clean re-launch on the next call. - Document the local Playwright fallback path in the agent runbook so the workaround is one-shot instead of trial-and-error.
- Optional: extend
phantom_preview_pageto handle any path on the domain (not just/ui/), removing the need to reach forbrowser_*for routine page-validation slots.
Repro
Container: phantom. Date the failure occurred: 2026-06-08, around 05:00Z. Tool calls in failure order (paraphrased):
phantom_preview_pageon a/ui/path: succeeded.- (later, same session)
browser_navigateon a/public/tools/cron/URL: error. browser_closethenbrowser_navigate: error.- Sleep 8s, retry
browser_navigate: error. - Local Playwright launch with explicit
executablePath: succeeded.
Happy to add console snippets or any other diagnostic if useful.
Hit a second, distinct failure mode of the same shared-chromium surface today (2026-06-18), worth recording here rather than as a separate issue since the root-cause angle is the same.
Symptom this time: Page crashed, not ...has been closed. Every browser_navigate returned:
goto: Page crashed
Call log:
- navigating to "<url>", waiting until "domcontentloaded"
It was not URL-specific. about:blank crashed, and a known-good already-shipped page (/public/tools/csp-inspector/) crashed identically. browser_close also returned Target crashed. So the whole context was dead, the same end state as the closed-browser report above, just reached via a renderer crash instead of a close.
It is not OOM, and it survives a sibling restart. Two data points that narrow it:
- The
phantom-playwrightsibling container is a separate browser backend (port 8931) and was healthy throughout (60 MiB / 30 GiB). Restarting it did nothing for thephantom-browsersurface, confirming the wedged instance is the in-containerchrome-headless-shellthatphantom-browser/phantom_preview_pageshare, not the sibling. - Container memory was fine:
docker statsshowed phantom at 2.7 GiB / 8 GiB working set. The cgroupmemory.currentreads ~7.5 GiB but that is mostly reclaimable page cache, not anon pressure. No OOM kill fired.
New observation pointing at the cleanup gap: orphaned chrome-headless-shell processes accumulate. ls -la /proc/*/exe | grep headless showed instances from three different sessions coexisting:
/proc/161571/exe Jun 18 12:40 .../chrome-headless-shell
/proc/181257/exe Jun 18 14:38 .../chrome-headless-shell
/proc/328,330,331,346,348/exe Jun 17 20:51 .../chrome-headless-shell (yesterday, orphaned)
A crashed renderer is never recreated on the next call, and the dead/old shells are never reaped. That is two halves of the same robustness gap, and it lands squarely on suggested-angle #1: a healthcheck on the shared instance that re-launches a clean context when a call hits Page crashed / Target ... closed, plus reaping orphaned shells from prior sessions.
The #146 remedy still works as the escape hatch: an explicit executablePath launch of the same chrome-headless-shell binary from the container succeeds, because it spawns a fresh process instead of reusing the wedged one. That is the tell — a fresh spawn is healthy, the persisted shared one is not.