question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v3.0.0 does not work in google cloud funtions node10 runtime

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:33
  • Comments:42 (6 by maintainers)

github_iconTop GitHub Comments

30reactions
sterencommented, May 11, 2020

Hi, I’m a PM on Google Cloud.

All OS packages available in Cloud Functions are listed on this page, libgbm1 is indeed not listed.

I will follow up with the Cloud Functions team to add it (internal bug number: 156270284)

11reactions
starrifycommented, May 23, 2020

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.1 binary is provided by package libgbm1.

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: libgbm1 and libwayland-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_PATH environment variable).

Please find below the proof-of-concept code that works for me (using the nodejs10 runtime):

$ cat package.json
{
  "name": "test",
  "main": "index.js",
  "dependencies": {
    "puppeteer": "3.1.0"
  },
  "scripts": {
    "postinstall": "for i in '1618226adb967b34670a06b6c9c28552717dfe0f434b9c6d7639144138948516 http://mirrors.kernel.org/ubuntu/pool/main/m/mesa/libgbm1_19.2.8-0ubuntu0~18.04.3_amd64.deb' '4f5cf9735170083aceb3d0c65ae64848102e9ef0aa0126effafcaf100f0f476c http://mirrors.kernel.org/ubuntu/pool/main/w/wayland/libwayland-server0_1.16.0-1ubuntu1.1~18.04.3_amd64.deb'; do wget ${i#* } && echo ${i% *} ${i##*/} | sha256sum -c && dpkg-deb -X ${i##*/} ./tmpdeb; done && cp ./tmpdeb/usr/lib/x86_64-linux-gnu/lib*.so* ./node_modules/puppeteer/.local-chromium/linux-*/chrome-linux/"
  }
}
$ cat index.js 
module.exports.render = async (req, res) => {
  const puppeteer = require('puppeteer');
  const browser = await puppeteer.launch({
    'env': {
      'LD_LIBRARY_PATH': puppeteer.executablePath().replace(/[^/]+$/, ''),
    },
    'dumpio': true,
  });
  const page = await browser.newPage();
  await page.goto('http://httpbin.org/get');
  res.status(200).send(await page.content());
  await page.close();
  await browser.close();
};

The checksum values above are obtained from the respective package pages: libgdm1 / libwayland-server0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Cloud Functions - Google Cloud
... deploying an event-driven function; Default runtime service account does not exist ... Logs too large in Node.js 10+, Python 3.8, Go 1.13,...
Read more >
Puppeteer not working with google cloud functions in Node 10 ...
I am using puppeteer v3.0.0 with nodejs 10 runtime. How can i resolve this error? Google Cloud Collective. node.js ...
Read more >
Manage functions | Cloud Functions for Firebase - Google
Deploy functions; Delete functions; Modify a function's name, region or trigger ... Cloud Functions 2.0.0 and higher allows a selection of Node.js runtime....
Read more >
Getting started with Cloud Functions (2nd gen)
In this codelab, you will learn about Google Cloud Functions (2nd gen). ... of your application does not impact the application performance.
Read more >
Incidents - Google Cloud Service Health
Cloud Billing usage reporting is experiencing issues, and Cost Management experience may show incomplete data. 25 Jul 2022. 9 days, 3 hours ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found