Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is "Page crashed!" error? #1321

Closed
gajus opened this issue Nov 8, 2017 · 29 comments
Closed

What is "Page crashed!" error? #1321

gajus opened this issue Nov 8, 2017 · 29 comments

Comments

@gajus
Copy link

gajus commented Nov 8, 2017

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?

@gajus
Copy link
Author

gajus commented Nov 8, 2017

I cannot replicate this issue outside of Docker.

@ebidel
Copy link
Contributor

ebidel commented Nov 8, 2017

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.

@ebidel ebidel closed this as completed Nov 8, 2017
@gajus
Copy link
Author

gajus commented Nov 8, 2017

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.

@RobinNagpal
Copy link

RobinNagpal commented Apr 3, 2018

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

@CQBinh
Copy link

CQBinh commented Oct 12, 2018

I met this on Ubuntu 16.04 (no docker)

@rotimi-best
Copy link

rotimi-best commented Nov 26, 2018

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)

@rotimi-best
Copy link

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.

@voxsoftware
Copy link

voxsoftware commented Mar 26, 2019

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

@xcrafter
Copy link

xcrafter commented Apr 8, 2019

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.

@SashaDesigN
Copy link

I got the same on Centos7.10

@painotpi
Copy link

painotpi commented Aug 14, 2019

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!

@lidijarad
Copy link

@Ta-Run , did you manage to find a fix? Also trying to run this on Windows 10 and getting the same error.

@iethem
Copy link

iethem commented Sep 12, 2019

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'] })

@antmelnyk
Copy link

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.

@saurabh147sharma
Copy link

saurabh147sharma commented Feb 3, 2020

@iethem @RobinNagpal @rotimi-best
I launch the browser with the following code:

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

I'm generating PDFs in docker. It's something like:

for(let i=0;i<=500;i++){
// call generate pdf function 
}

After creating around 20-25 PDFs it gives uncaughtException.

Error: Page crashed! at Page._onTargetCrashed (/node_modules/puppeteer/lib/Page.js:216:24) at CDPSession.<anonymous> (/node_modules/puppeteer/lib/Page.js:124:56) at CDPSession.emit (events.js:223:5) at CDPSession.EventEmitter.emit (domain.js:475:20) at CDPSession._onMessage (/node_modules/puppeteer/lib/Connection.js:200:12) at Connection._onMessage (/node_modules/puppeteer/lib/Connection.js:112:17) at WebSocket.<anonymous> (/node_modules/puppeteer/lib/WebSocketTransport.js:44:24) at WebSocket.onMessage (/node_modules/ws/lib/event-target.js:120:16) at WebSocket.emit (events.js:223:5) at WebSocket.EventEmitter.emit (domain.js:475:20) at Receiver.receiverOnMessage (/node_modules/ws/lib/websocket.js:789:20) at Receiver.emit (events.js:223:5) at Receiver.EventEmitter.emit (domain.js:475:20) at Receiver.dataMessage (/node_modules/ws/lib/receiver.js:422:14) at Receiver.getData (/node_modules/ws/lib/receiver.js:352:17) at Receiver.startLoop (/node_modules/ws/lib/receiver.js:138:22), Promise { <rejected> Error: Page crashed! at Page._onTargetCrashed (/node_modules/puppeteer/lib/Page.js:216:24) at CDPSession.<anonymous> (/node_modules/puppeteer/lib/Page.js:124:56) at CDPSession.emit (events.js:223:5) at CDPSession.EventEmitter.emit (domain.js:475:20) at CDPSession._onMessage (/node_modules/puppeteer/lib/Connection.js:200:12) at Connection._onMessage (/node_modules/puppeteer/lib/Connection.js:112:17) at WebSocket.<anonymous> (/node_modules/puppeteer/lib/WebSocketTransport.js:44:24) at WebSocket.onMessage (/node_modules/ws/lib/event-target.js:120:16) at WebSocket.emit (events.js:223:5) at WebSocket.EventEmitter.emit (domain.js:475:20) at Receiver.receiverOnMessage (/node_modules/ws/lib/websocket.js:789:20) at Receiver.emit (events.js:223:5) at Receiver.EventEmitter.emit (domain.js:475:20) at Receiver.dataMessage (/node_modules/ws/lib/receiver.js:422:14) at Receiver.getData (/node_modules/ws/lib/receiver.js:352:17) at Receiver.startLoop (/node_modules/ws/lib/receiver.js:138:22) }
Any idea why I'm getting this error?

@rotimi-best
Copy link

@saurabh147sharma Did you try increasing the memory of your docker container as mentioned in this comment below? Also run your nodejs script and simultaneously run this command htop in your terminal to see how much memory is used while the script runs. It will help you know how much memory is required for your task.

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

@saurabh147sharma
Copy link

@rotimi-best
Yes, it is 2048 MiB and I don't know why I'm facing this issue because my pdf is not too big it has just 3 pages.
FYI... I'm using AWS Batch.

wataruoguchi added a commit to wataruoguchi/covid19_nagano_scraper that referenced this issue Apr 4, 2020
- s/bukan-haien/corona/

Also, we've got an error: `UnhandledPromiseRejectionWarning: Error: Page crashed!`
Resolved with this:

- puppeteer/puppeteer#1321 (comment)
@aburd
Copy link

aburd commented Apr 15, 2020

I was getting similar errors running my tests on CircleCI.
Locally it was fine, but it would fail when running inside the CircleCI docker containers.

After employing @RobinNagpal suggestion of using the --disable-dev-shm-usage flag, tests started to run again. But after some refactoring of my code, the tests would fail as before. It turns out that jest tests run in parallel by default, and my refactoring had resulted in a lot more tests running at the same time, all starting puppeteer at once which used up more memory than allotted.

I needed to run them sequentially to reduce the memory usage and after adding this flag to my jest test command: --runinband, things are working again.

This is a rather specific case, but I hope it helps someone.

@Brmm
Copy link

Brmm commented Jun 9, 2020

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'],
  });

@Georgegriff
Copy link

Georgegriff commented Jun 10, 2020

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

@aadhikary
Copy link

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.

@vatsaljrathod
Copy link

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.

@mr-moon
Copy link

mr-moon commented Jul 20, 2020

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

@entrptaher
Copy link
Contributor

entrptaher commented Jul 21, 2020

Previously we could run 10 chrome at once without any problem inside docker, now same code fails with running 2-3 at once, sometimes even just one crashes it. The problem is the issue is too old and we might need to create different issue.

Also we need to mention we tried using puppeteer-extra, applied all different kind of hacks mentioned above, which previously worked without any issue.

Now just taking a simple screenshot fails randomly.

Puppeteer version 3.0

possibly-not added a commit to possibly-not/gitbook-printer that referenced this issue Sep 8, 2020
Added '--disable-dev-shm-usage', '--disable-gpu'  into the puppeteer launch in order to fix a "(node:117132) UnhandledPromiseRejectionWarning: Error: Page crashed!" error I was constantly getting. 
Thank you to puppeteer/puppeteer#1321 (comment) for the fix aha! I have no knowledge of Javascript/Node but this seems to work for me.
@0zul
Copy link

0zul commented Jun 5, 2021

Page crashed errors are caused because of certain website animation causing huge stress on the CPU, RAM and GPU. This can be easily fixed by adding some sort of delay before capturing the screenshot or completely avoiding taking a screenshot from the website that previously caused this error. All the above resolutions can be used to fix this but addition to that, try adding delay before capturing screenshots.

@FaraziF
Copy link

FaraziF commented Sep 30, 2021

Still, I am facing this problem. When I run test scenario from Github Action

Puppeteer page error Error: Page crashed!
    at Page._onTargetCrashed (/home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:324:28)
    at /home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:162:57
    at /home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at CDPSession.emit (/home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at CDPSession._onMessage (/home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:234:18)
    at Connection._onMessage (/home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:111:25)
    at WebSocket.<anonymous> (/home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/puppeteer/lib/cjs/puppeteer/node/NodeWebSocketTransport.js:13:32)
    at WebSocket.onMessage (/home/runner/work/codeceptjs-continuous-integration/codeceptjs-continuous-integration/node_modules/ws/lib/event-target.js:132:16)

@PZ01
Copy link

PZ01 commented Dec 29, 2021

We are using puppeteer through Gitlab CI with codeceptjs. I haven't looked at the specs of the container's spawned by the Gitlab Runner to run the jobs, but we stopped getting this issue by:

  1. Upgrading puppeteer from 9.9.1 -> 13.0.1 (which has a newer Chromium image)
  2. Reducing number of workers when running codecept run-workers # command
  3. Re-organizing the feature files to find a balance between jobs/workers.

The first point was most important, the other two are mostly optimizations.

@chang-ke
Copy link

chang-ke commented Jun 8, 2022

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'] })

it works for me in Windows11, thanks

refi93 added a commit to vacuumlabs/adalite that referenced this issue Dec 16, 2022
Inspired by puppeteer/puppeteer#1321
where no-sandbox option was being used - not sure why it works though
refi93 added a commit to vacuumlabs/adalite that referenced this issue Dec 16, 2022
Inspired by puppeteer/puppeteer#1321
where no-sandbox option was being used - not sure why it works though
refi93 added a commit to vacuumlabs/adalite that referenced this issue Dec 17, 2022
Inspired by puppeteer/puppeteer#1321
where no-sandbox option was being used - not sure why it works though
@kat15
Copy link

kat15 commented Nov 2, 2023

hi.. I'm getting the same error... (in kubuntu, not docker)
yarn run test:voyeur yarn run v1.22.19 $ HEADLESS=false jest --runInBand (node:37420) UnhandledPromiseRejectionWarning: Error: Page crashed! at Page._onTargetCrashed (/node_modules/puppeteer/lib/Page.js:215:24) at CDPSession.<anonymous> (/node_modules/puppeteer/lib/Page.js:123:56) at CDPSession.emit (events.js:400:28) at CDPSession._onMessage (/node_modules/puppeteer/lib/Connection.js:200:12) at Connection._onMessage (/node_modules/puppeteer/lib/Connection.js:112:17) at runNextTicks (internal/process/task_queues.js:60:5) at listOnTimeout (internal/timers.js:526:9) at processTimers (internal/timers.js:500:7) (Use node --trace-warnings ...to show where the warning was created) (node:37420) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:37420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests