Last Updated: March 23, 2023
·
101
· Blitline Support

Puppeteer Crashing (Page Crashed!) inside Docker

Sometimes Puppeteer will throw weird crashes with output like:

this.emit('error', new Error('Page crashed!'));

The Fix:
When using Chromium and Puppeteer, Chromium will use the /dev/shm (Ramdisk) for rendering.
By default, Docker will only allocate 64MB for /dev/shm. You can bump up this value by adding "--shm-size=2gb" to your Docker "run" command, thus assigning /dev/shm a 2GB allowance. This can prevent Chromium and Puppeteer from crashing.