puppeteer: v3.0.0 does not work in google cloud funtions node10 runtime
Tell us about your environment:
- Puppeteer version: 3.0.0
- Platform / OS version: GCP functions
- URLs (if applicable):
- Node.js version: 10 (beta - in cloud functions)
I see that the latest release 3.0.0 does not support node8 anymore. So, I changed the runtime to 10 (beta) in my cloud functions and got this below error in the logs
Failed to launch the browser process!
/workspace/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
I tried puppeteer v2.1.1 with node10 runtime and it worked.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 34
- Comments: 42 (6 by maintainers)
Commits related to this issue
- DOWNGRADE puppeteer until https://github.com/puppeteer/puppeteer/issues/5704 is fixed at netlify — committed to storybookjs/storybook by ndelangen 4 years ago
- Downgrade puppeteer to 2.1.1 Because of https://github.com/puppeteer/puppeteer/issues/5704 causing failed Netlify builds — committed to alexpeattie/alexpeattie.com by alexpeattie 4 years ago
- First version of Puppeteer web scraper. Starts on port 4000. Supports LinkedIn, Indeed, ZipRecruiter, StartupJobs, SimplyHired, and various BuiltIn city sites. — committed to yankidank/Codify by yankidank 4 years ago
Hi, I’m a PM on Google Cloud.
All OS packages available in Cloud Functions are listed on this page,
libgbm1is indeed not listed.I will follow up with the Cloud Functions team to add it (internal bug number: 156270284)
I’d like to share a somehow-dirty-but-working fix, hoping it might help people like me that would like to try newer versions of Chromium on GCF (Google Cloud Functions) without waiting for the platform’s update.
It’s known from this page that the Node.js 8 & 10 environments on GCF use Ubuntu 18.04, on which the
libgbm.so.1binary is provided by packagelibgbm1.By analyzing the package dependencies, examining the list of system packages of the Node.js environment on GCF, and some live inspection of the function execution environment, it’s known that there are (only) two additional packages that we need:
libgbm1andlibwayland-server0.Due to privilege limits we may not install system packages directly. However it’s okay to fetch the binaries at function deployment time (via npm’s pre/post script hooks) and explicitly ask the dynamic linker to use such binaries (via the
LD_LIBRARY_PATHenvironment variable).Please find below the proof-of-concept code that works for me (using the
nodejs10runtime):The checksum values above are obtained from the respective package pages:
libgdm1/libwayland-server0.expected in 2 weeks?
hi @ar-naseef,
Above puppeteer 3.0.0 you need to install libgbm1 as mentioned as solution in #5661
See in required Debian dependencies here: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
(Docs were extended with v3.0.1)
For me adding it in workflows it fixed the error in Github Actions (using Ubuntu latest).
Cheers
@steren Do you have any progress or schedule to fix it?
For those who wants to check on updates, it is happening here: https://issuetracker.google.com/issues/156772387
Same here puppeteer v3 fails to run on nodejs10 cloud function and fails with:
Which should not be the case based on Running Puppeteer on Google Cloud Functions Doc
Version 2.1.1 works fine.
We are still pending the roll out of the change. It’s expected in 2 weeks.
in the meantime, you should be able to run
v3.0.0on Cloud Run, which allows you to bring a container that would have the missing OS packagelibgbm1.Still not fixed? Seems cloud functions are more of a problem than a solution.
I fix it by downgrade to
2.1.1lol then config withIf the features of puppeteer 3 are a must for you: check out Installing Google Cloud SDK, like this you will be able to apply the apt-get install even on temporary instances.
I updated puppeteer to the latest version(“puppeteer”: “^5.4.1” / “@types/puppeteer”: “^3.0.4”) and confirmed it works in cloud functions.
This is not possible for firebase users (which runs on google cloud).
Sure thing.
But I am not sure how we can install packages in cloud functions. Functions run in temporary instances.
We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!
If anyone is trying to make it work on Cloud Function with Node 14, I had to use the following to make it work:
without the
argsthe browser was never launched, and the function timed out. I’m not sure which one are the absolutely necessary to make it work.After poking around some more, I figured out that it was this line
await page.setJavaScriptEnabled(true);that is causing it to hang.
I tried too and i confirm, it doesn’t work with version 12 ! Thanks
sure man:
Leaving a comment because this messed me up for a night and maybe it’ll help someone:
If you are going to downgrade when using firebase functions remember to run npm install in your functions folder. They do not run it on the cloud side - you upload your dependencies with your function. So you can change it to say “puppeteer”:“2.1.1” but it won’t work until after you run npm install. Downgrading worked just fine for me after I ran npm install but I spent a whole night trying to figure that out.
Looks promising