7 Problems with Puppeteer PDF Generation (And How to Fix Them)
Memory leaks, cold starts, Docker headaches, font rendering issues — the common Puppeteer PDF problems and their solutions.
1. Memory leaks
Chromium is notorious for memory leaks, especially when generating many PDFs in sequence. Each page.pdf() call may not fully release memory, causing your process to grow over time. The common workaround is to restart the browser every N conversions — but this adds latency and complexity.
2. Cold start latency
Launching Chromium takes 1-5 seconds. In serverless environments, every function invocation is a cold start. Even with browser pooling on traditional servers, the first request after idle takes seconds. pdfRelay's Rust engine starts in under 1ms — there's no browser to launch.
3. Docker image bloat
Adding Chromium to your Docker image adds 400-600MB. Your CI builds take longer, your deploys are slower, and your container registry costs more. Many teams maintain a separate "PDF service" Docker image just to isolate the Chromium dependency.
4. Font rendering inconsistencies
Fonts render differently on macOS vs Linux vs Windows. Your PDF may look perfect locally but have wrong character spacing on your CI server. The fix? Install specific fonts in your Docker image and hope they match.
5. Zombie processes
If your Node.js process crashes between browser.launch() and browser.close(), you get a zombie Chrome process. These accumulate over time and consume all available memory. You need a process manager (PM2, systemd) with health checks to detect and kill them.
6. Concurrent generation limits
Each PDF generation needs its own browser tab (200-400MB). Generating 10 PDFs simultaneously needs 2-4GB of RAM. You need queue-based processing to limit concurrency — more infrastructure to build and maintain.
7. Print CSS support gaps
Chromium's page.pdf() doesn't support all CSS print features consistently. @page margin boxes, running headers/footers, page counters, and orphans/widows can be buggy or unsupported.
The solution
If you're hitting any of these problems, an API-based approach eliminates all of them. Send your HTML, get a PDF. No Chromium, no Docker, no memory management. Just the HTML and CSS you already know how to write — rendered by a purpose-built Rust engine in milliseconds.