DEV Community

Discussion on: How We Fixed a Puppeteer Memory Leak in a Laravel IoT App

Collapse
 
sleywill_45 profile image
Alex Serebriakov

memory leaks with puppeteer are a classic — browser.close() in finally blocks helps but zombie processes still accumulate over time in long-running services. if screenshot/PDF generation is the part that's leaking, moving it to an API call (like snapapi.pics) offloads the browser process lifecycle entirely. your app just fires HTTP requests, no chrome to leak

Collapse
 
antoniosthanasisgit profile image
Antonios Thanasis

yeah totally agree — puppeteer leaks are kind of inevitable in long-running services 😅 even with finally blocks you still end up chasing zombie processes after a while

offloading screenshots/PDFs to an API is actually a really nice approach, especially if that’s the main source of the leaks. not having to manage the browser lifecycle at all is a big win

in our case we wanted to keep everything self-contained, but yeah for a lot of setups that trade-off (less control vs more stability) is definitely worth it 👍