Skip to content
Latchkey

Puppeteer "Protocol error ... Target closed" in CI

A "Protocol error ... Target closed" means the page or browser Puppeteer was driving went away mid-command, so the DevTools connection dropped. In CI this is usually a renderer crash from limited /dev/shm or an out-of-memory kill.

What this error means

A test throws "Protocol error (Runtime.callFunctionOn): Target closed" or "Protocol error (Page.navigate): Target closed", often intermittently, on a container runner.

puppeteer
Error: Protocol error (Runtime.callFunctionOn): Target closed.
    at .../puppeteer/lib/cjs/puppeteer/common/Connection.js
ProtocolError: Protocol error (Page.navigate): Target closed.

Common causes

The renderer crashed on small /dev/shm

The container default 64 MB /dev/shm starves Chromium, so the renderer process dies and the target closes.

The browser was killed by the OOM killer

A memory-heavy page or many parallel pages exhaust the runner memory, so the kernel kills the browser mid-operation.

How to fix it

Avoid the /dev/shm crash

  1. Launch with --disable-dev-shm-usage so Chromium uses /tmp.
  2. Or raise the container shared memory size.
  3. Re-run so the renderer no longer crashes under memory pressure.
JavaScript
const browser = await puppeteer.launch({
  args: ['--no-sandbox', '--disable-dev-shm-usage'],
});

Reduce memory pressure

Close pages you finish with and limit how many browser contexts run in parallel so the runner does not run out of memory.

JavaScript
const page = await browser.newPage();
try { /* ... */ } finally { await page.close(); }

How to prevent it

  • Use --disable-dev-shm-usage or a larger --shm-size in containers.
  • Close pages and contexts promptly to bound memory.
  • Cap parallel browser instances to the runner memory.

Frequently asked questions

What causes ""Protocol error ... Target closed""?
The container default 64 MB /dev/shm starves Chromium, so the renderer process dies and the target closes.
How do I fix "Protocol error ... Target closed"?
Avoid the /dev/shm crash

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card