puppeteer: What is "Page crashed!" error?

Steps to reproduce

N/A (Not able to reproduce consistently.)

Tell us about your environment:

What steps will reproduce the problem?

Please include code that reproduces the issue.

const defaultPuppeteerOptions: Object = {
  args: [
    '--no-sandbox',
    '--disable-setuid-sandbox'
  ],
  devtools: false,
  headless: true,
  ignoreHTTPSErrors: true,
  slowMo: 0
};

const defaultViewport = {
  deviceScaleFactor: 1,
  hasTouch: false,
  height: 1024,
  isLandscape: false,
  isMobile: false,
  width: 1280
};

const browser = await puppeteer.launch({
  ...defaultPuppeteerOptions
});

const page = await browser.newPage();

await page.setViewport(defaultViewport);

await page.goto('https://www.myvue.com/');

What is the expected result?

No error.

What happens instead?

unhandledRejection Error: Page crashed!
   at Page._onTargetCrashed (/srv/node_modules/puppeteer-edge/lib/Page.js:102:24)
   at Session.Page.client.on.event (/srv/node_modules/puppeteer-edge/lib/Page.js:97:56)
   at emitOne (events.js:115:13)
   at Session.emit (events.js:210:7)
   at Session._onMessage (/srv/node_modules/puppeteer-edge/lib/Connection.js:210:12)
   at Connection._onMessage (/srv/node_modules/puppeteer-edge/lib/Connection.js:105:19)
   at emitOne (events.js:115:13)
   at WebSocket.emit (events.js:210:7)
   at Receiver._receiver.onmessage (/srv/node_modules/ws/lib/WebSocket.js:143:47)
   at Receiver.dataMessage (/srv/node_modules/ws/lib/Receiver.js:389:14)
   at Receiver.getData (/srv/node_modules/ws/lib/Receiver.js:330:12)
   at Receiver.startLoop (/srv/node_modules/ws/lib/Receiver.js:165:16)
   at Receiver.add (/srv/node_modules/ws/lib/Receiver.js:139:10)
   at Socket._ultron.on (/srv/node_modules/ws/lib/WebSocket.js:139:22)
   at emitOne (events.js:115:13)
   at Socket.emit (events.js:210:7)
   at addChunk (_stream_readable.js:266:12)
   at readableAddChunk (_stream_readable.js:253:11)
   at Socket.Readable.push (_stream_readable.js:211:10)
   at TCP.onread (net.js:585:20)

I am intermittently getting “Page crashed!” error.

What does the error mean?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 29 (2 by maintainers)

Commits related to this issue

Most upvoted comments

This worked

By default, Docker runs a container with a /dev/shm shared memory space 64MB.
 This is typically too small for Chrome and will cause Chrome to crash when rendering large pages. 
To fix, run the container with docker run --shm-size=1gb to increase the size of /dev/shm. 
Since Chrome 65, this is no longer necessary. 
Instead, launch the browser with the --disable-dev-shm-usage flag:

const browser = await puppeteer.launch({
  args: ['--disable-dev-shm-usage']
});

Copied from https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#tips

I still had this Error: Page crashed with '--disable-dev-shm-usage' on Ubuntu 16.04 even with

const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-dev-shm-usage'] });

UnhandledPromiseRejectionWarning: Error: Page crashed!
    at Page._onTargetCrashed (/prb/node_modules/puppeteer/lib/Page.js:161:24)
    at CDPSession.Page.client.on.event (/prb/node_modules/puppeteer/lib/Page.js:137:56)
    at CDPSession.emit (events.js:180:13)
    at CDPSession._onMessage (/prb/node_modules/puppeteer/lib/Connection.js:232:12)
    at Connection._onMessage (/prb/node_modules/puppeteer/lib/Connection.js:119:19)
    at WebSocket.emit (events.js:180:13)
    at Receiver.receiverOnMessage (/prb/node_modules/ws/lib/websocket.js:720:20)
    at Receiver.emit (events.js:180:13)
    at Receiver.dataMessage (/prb/node_modules/ws/lib/receiver.js:414:14)
    at Receiver.getData (/prb/node_modules/ws/lib/receiver.js:346:17)
    at Receiver.startLoop (/prb/node_modules/ws/lib/receiver.js:133:22)
    at Receiver._write (/prb/node_modules/ws/lib/receiver.js:69:10)
    at doWrite (_stream_writable.js:410:12)
    at writeOrBuffer (_stream_writable.js:396:5)
    at Receiver.Writable.write (_stream_writable.js:294:11)
    at Socket.socketOnData (/prb/node_modules/ws/lib/websocket.js:795:35)

That answer did not explain what the error means.

For anyone running into this issue on K8S, the issue is that /dev/shm allocation is too small (64MB default).

You cannot override Docker shm configuration in K8S, however, there is this workaround https://stackoverflow.com/a/46434614/368691.

I solve my issue already. The problem was that there wasn’t enough memory in my VM so it kept giving me this error. Kill all unnecessary processes and running puppeteer one more time did the trick.

I met this on Ubuntu 16.04 (no docker)

I faced the same problem for getting full html content on k8s. I tried --disable-dev-shm-usage parameter but it did not work. I fixed the problem using --disable-gpu parameter.

await puppeteer.launch({ executablePath: '/usr/bin/chromium-browser', args: ['--disable-gpu', '--no-sandbox', '--lang=en-US', '--disable-setuid-sandbox', '--disable-dev-shm-usage'] })

Getting this error on windows 10 (no docker). Just created a basic app,

Nodev10.16.2

(async function main() {
  try {
    const browser = await puppeteer.launch({ headless: false })
    const page = await browser.newPage()
    page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36')

    await page.goto('https://mywebsite.com')
    await page.waitForSelector('#myselector')

    console.log("It's working!")

  } catch (error) {
    console.log('An error occurted!\n')
    console.log(error)
  }
})()

Get the following error,

UnhandledPromiseRejectionWarning: Error: Page crashed!

Yes, it might be an issue with the latest version. We recently switched to 3.3.0 version and started getting this issue. We reverted back to 2.1.1 our older version and its working without any issue.

Crushing on Windows even before any code with empty test file.

It launches 2 Chrome “Aw, snap!” tabs. In console: (node:23788) UnhandledPromiseRejectionWarning: Error: Page crashed!

Headless: true works fine though.

have the same issue, the question here is why is an unhandled promise rejection? How can I catch that error? because looks that normal try catch not working

There’s an example Docker setup and tips and tricks when hitting issues like this in https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker.

Following the doc (https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker) I thought we do not need to provide shm_size: ‘2gb’ as this was handled by using: const browser = await puppeteer.launch({ args: ['--disable-dev-shm-usage'] });

I feel like this this change has somehow been broken.

I was seeing this in docker, the problem went away when i updated my docker-compose.yaml to include shm_size i set my shm_size to 2GB.

e.g.

    
version: '3.3'
services:
  runner:
    image: e2e-runner
    env_file:
      - .env
    build:
      context: .
      dockerfile: Dockerfile
    shm_size: '2gb'
    container_name: tests-runner
    network_mode: host

There might be a chance if your machine is running out of space. I’ve faced a similar issue, while my system was running out of space. Once I cleared the issue, it seems to be working fine.

Getting same issues with v3. All been good on v2 with same code.

On docker following the troubleshoot and using the local executable did solve the problem for me. Not using the local executable throws “Page Crashed!”

await puppeteer.launch({
    executablePath: 'google-chrome-unstable',
    args: [
      '--no-sandbox', 
      '--disable-setuid-sandbox', 
      '--disable-dev-shm-usage', 
      '--disable-gpu'],
  });