Generating PDFs from HTML in Node.js (and why I stopped using Puppeteer)
Last year I was adding invoice generation to a side project. Three days later I was still debugging Puppeteer on a DigitalOcean droplet. Blank PDFs, fonts not loading, the process eating 400+MB of ...

Source: DEV Community
Last year I was adding invoice generation to a side project. Three days later I was still debugging Puppeteer on a DigitalOcean droplet. Blank PDFs, fonts not loading, the process eating 400+MB of RAM for a single render. I shipped something that worked 90% of the time and crossed my fingers. If that sounds familiar, here's what I've learned since. What's actually wrong with Puppeteer Nothing, on your laptop. The problems start when you deploy. Memory. Chromium is a full browser. Each instance takes 300–500MB. If a render crashes mid-way, the browser process doesn't always clean up after itself. Run this under any real traffic and you'll watch your server slowly run out of memory. Cold starts. Spinning up a Chromium instance takes 1–3 seconds. Every time. If you're on a serverless function that scales to zero, that latency hits every first request. Fonts and assets. Puppeteer runs sandboxed. Anything loaded from a relative path or file:// URL either fails silently or renders wrong. The