heroku-buildpack-google-chrome icon indicating copy to clipboard operation
heroku-buildpack-google-chrome copied to clipboard

Intermittent page crashes with puppeteer

Open ColemanGariety opened this issue 7 years ago • 6 comments

I'm trying to take screenshots via puppeteer, but I get intermittent Error: Page crashed! errors. It crashes more frequently when there are more images on the page, so I'm assuming that there's some sort of chrome memroy issue, but I'm no expert.

I'm running on the "hobby" tier.

I'm launching puppeteer this way:

  const browser = await puppeteer.launch({
    args: [
      '--remote-debugging-port=9222',
      '--no-sandbox',
      '--disable-setuid-sandbox',
      '--disable-gpu',
    ],
    dumpio: true,
  })

The errors aren't very helpful, but here's one:

2018-01-12T11:34:11.526008+00:00 app[web.1]: Error: Page crashed!
2018-01-12T11:34:11.526011+00:00 app[web.1]:     at Page._onTargetCrashed (/app/node_modules/puppeteer/node6/Page.js:128:24)
2018-01-12T11:34:11.526012+00:00 app[web.1]:     at Session.Page.client.on.event (/app/node_modules/puppeteer/node6/Page.js:123:56)
2018-01-12T11:34:11.526013+00:00 app[web.1]:     at emitOne (events.js:96:13)
2018-01-12T11:34:11.526014+00:00 app[web.1]:     at Session.emit (events.js:188:7)
2018-01-12T11:34:11.526015+00:00 app[web.1]:     at Session._onMessage (/app/node_modules/puppeteer/node6/Connection.js:288:12)
2018-01-12T11:34:11.526016+00:00 app[web.1]:     at Connection.<anonymous> (/app/node_modules/puppeteer/node6/Connection.js:157:19)
2018-01-12T11:34:11.526017+00:00 app[web.1]:     at next (native)
2018-01-12T11:34:11.526017+00:00 app[web.1]:     at step (/app/node_modules/puppeteer/node6/Connection.js:120:24)
2018-01-12T11:34:11.526018+00:00 app[web.1]:     at Promise (/app/node_modules/puppeteer/node6/Connection.js:138:12)
2018-01-12T11:34:11.526019+00:00 app[web.1]:     at new Promise (/app/node_modules/core-js/modules/es6.promise.js:164:7)

Thanks for your assistance.

EDIT: Oh, and I haven't tried running Docker locally, but the problem seems similar to many Docker users.

ColemanGariety avatar Jan 12 '18 11:01 ColemanGariety

I am having this same issue, only on heroku. Works fine everywhere else. I have gone through all the docs, adding the buildpack, setting the right flags, etc. Help!

remotezygote avatar Jan 16 '18 19:01 remotezygote

@JacksonGariety @remotezygote has there been any update on your end? I think im running into this issue on heroku as well

phamcharles avatar Mar 16 '18 21:03 phamcharles

@JacksonGariety @remotezygote have you guys found a solution to this, I am also having the same issue. Seems like it occurs only on heroku and that too recently earlier it was fine.

rahulkumar66 avatar Mar 20 '18 11:03 rahulkumar66

I was experiencing this issue and adding the --disable-dev-shm-usage flag fixed it.

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

dhersam avatar Apr 12 '18 17:04 dhersam

@dhersam This seems to fix the issue i think the issue is that we are running out of memory and since heroku doesn't have any swap space thus resulting in crash . One can also --single-process to further improve memory usage

rahulkumar66 avatar Apr 13 '18 07:04 rahulkumar66

Anyone else getting the following:

UnhandledPromiseRejectionWarning: Error: Failed to launch chrome! [0312/205733.776751:FATAL:zygote_host_impl_linux.cc(127)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

when passing those flags?

mrispoli24 avatar Mar 12 '19 20:03 mrispoli24