How do I deploy Puppeteer onto Heroku?

Viewed 1185

For whatever reason, I am unable to deploy puppeteer correctly on to heroku. It builds, but when I run it, I get the application error page. When I check the logs, I get:

2020-09-09T22:44:38.942371+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
2020-09-09T22:44:38.942389+00:00 app[web.1]: [0909/224438.137880:FATAL:zygote_host_impl_linux.cc(117)] 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.

Which is telling me 1) the browser doesn't launch for whatever reason, and 2) that there's no sandbox.

The basic code I'm using is this:

const browser = await puppeteer.launch(
{
    headless: false,
    args: ["no-sandbox", "--disable-setuid-sandbox"],
});

As you can see, I've already tried the no-sandbox option that I've seen on SO. I've tried setting headless to true and false, no difference.

Here is my webpacks I have on Heroku.

https://github.com/jontewks/puppeteer-heroku-buildpack
https://github.com/heroku/heroku-buildpack-google-chrome
heroku/nodejs

Do I need more? Do I need one specifically for Chromium?

1 Answers

Okay, first I had a typo. It's --no-sandbox.

Second, I had to download a new webpack onto Heroku called heroku-buildpack-chrome-headless.

Related