PDFPipe

Blog

Why Puppeteer PDF crashes in production

It worked in development and falls over the moment real traffic arrives. The crash is almost always one of four causes. Here is how to recognize each, and what actually fixes it.

1. The slow memory leak

Chromium memory climbs render after render. A long-lived browser or process eventually hits the limit and is OOM-killed mid-request. The fix is to recycle browsers after a fixed number of renders and to watch resident memory, not to hope it levels off.

2. Unbounded concurrency

Each browser is expensive. When ten requests arrive at once and each launches or drives a browser, you exhaust memory and CPU, page.pdf() hangs, and tabs crash. A strict concurrency limiter with a queue in front of rendering is mandatory.

3. Orphaned processes

If a render throws before cleanup, the browser is never closed and keeps holding memory. Thousands of these over a day look exactly like a leak. Always close pages and browsers in a finally block, and reap stragglers.

4. Serverless limits

On serverless, a full Chromium binary barely fits, cold starts launch a browser on the request path, and tight memory ceilings make a single heavy render tip the function over. This is why so many timeout and crash reports come from Lambda and similar platforms.

The durable fix

You can engineer around all four with recycling, limiters, careful cleanup, and tuned containers. Or you can stop running the browser and call a render API, which handles isolation, recycling, and scaling so the crash class disappears. Same Chromium-quality output, none of the failure modes.

Frequently asked

Why does page.pdf() time out under load?

Too many concurrent browsers exhaust memory and CPU, so renders stall. Add a concurrency limiter and queue, or offload rendering to an API that scales independently.

Is the Puppeteer crash a memory leak or a process leak?

Often both: Chromium memory grows over time, and renders that throw before cleanup orphan browsers. Recycle browsers and always close them in finally to address each.

500 free documents a month, flat pricing after that, and a live playground you can try without signing up.