Back to articles
Why I Stopped Self-Hosting Puppeteer (And Built a Screenshot API Instead)

Why I Stopped Self-Hosting Puppeteer (And Built a Screenshot API Instead)

via Dev.to WebdevOpSpawn

I used to think self-hosting Puppeteer was the right way to handle browser automation. Full control, no vendor lock-in, runs anywhere. What could go wrong? Everything, it turns out. The Setup That Seemed Fine It started with a simple requirement: generate PDF invoices and take screenshots of rendered pages for a SaaS product. Puppeteer seemed like the obvious choice. Install it, spin up a headless Chrome, done. The first week was great. Screenshots worked. PDFs rendered beautifully. I shipped it and moved on. The First Sign Three weeks later, my staging server ran out of memory. I traced it back to Puppeteer. Specifically: Chrome processes that didn't get cleaned up properly when requests errored out. Each screenshot attempt spawned a browser instance. Error cases — network timeouts, bad URLs, malformed HTML — left zombie Chrome processes dangling in memory. Fix: wrap everything in try/catch, always call browser.close() . Got it. Except browser.close() doesn't always work when the brow

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles