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

Failed to launch chrome #3422

Closed
mbrevda opened this issue Oct 17, 2018 · 30 comments
Closed

Failed to launch chrome #3422

mbrevda opened this issue Oct 17, 2018 · 30 comments

Comments

@mbrevda
Copy link

mbrevda commented Oct 17, 2018

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.9.0
  • Platform / OS version: Google Cloud Functions
  • Node.js version: 8

What steps will reproduce the problem?

Deploying the following code to GCF. Try executing it.

code
 exports.test = async (req, res) => {
  const puppeteer = require('puppeteer')
  const browser = await puppeteer.launch({
    args: ['--no-sandbox']
  })

  const pages = await browser.pages()
  const page = pages[0]

  await page.goto('https://www.google.com')
  await browser.close()
  return res.status(200).send('')
}

What happens instead?

gcloud functions call test --project=[redacted] --region=europe-west1
error: |
  Error: function crashed. Details:
  Failed to launch chrome!
  /srv/node_modules/puppeteer/.local-chromium/linux-594312/chrome-linux/chrome: error while loading shared libraries: libXcursor.so.1: cannot open shared object file: No such file or directory
@greatwitenorth
Copy link

Yep I'm seeing the same thing. This is causing issues on our production service right now.

@greatwitenorth
Copy link

This is likely related to this issue:
#3424

@AmberAAA
Copy link

i see the same problem

Tell us about your environment:

  • Puppeteer version: 1.9.0
  • Platform / OS version: CentOS Linux release 7.5.1804 (Core)
  • Node.js version: 8.12

What steps will reproduce the problem?

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

What happens instead?

[root@host imgs]# node ./src/index.js 
(node:1864) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
/home/imgs/node_modules/puppeteer/.local-chromium/linux-594312/chrome-linux/chrome: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/home/imgs/node_modules/puppeteer/lib/Launcher.js:339:14)
    at Interface.helper.addEventListener (/home/imgs/node_modules/puppeteer/lib/Launcher.js:328:50)
    at emitNone (events.js:111:20)
    at Interface.emit (events.js:208:7)
    at Interface.close (readline.js:368:8)
    at Socket.onend (readline.js:147:10)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
(node:1864) 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(). (rejection id: 1)
(node:1864) [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.

@mbrevda
Copy link
Author

mbrevda commented Oct 19, 2018

@steren is this something that your team can look at?

@steren
Copy link
Contributor

steren commented Oct 19, 2018

Thanks for the report. The issue seems to be related to the execution environment. We will investigate internally

Do you confirm it works with an older version of the module?

@shashank-
Copy link

@steren It is working with version upto 1.7.0. Anything higher so far has failed, same error.

@greatwitenorth
Copy link

I can also confirm that 1.7.0 is working for us.

@ghost
Copy link

ghost commented Oct 23, 2018

I see the same error. I changed environment and tried sometimes, I write my error informations.

Tell us about your environment:

  • Puppeteer version: 1.6.2, 1.7.0, 1.8.0 and 1.9.0
  • Platform / OS version: Google Cloud Functions
  • Node.js version: 8
browser = await puppeteer.launch({headless: true, userDataDir: '/tmp/', args: ['--disable-gpu', '--disable-dev-shm-usage', '--disable-setuid-sandbox', '--no-first-run', '--no-sandbox', '--no-zygote', '--single-process']});

What happens?

 severity:  "ERROR"  
 textPayload:  "Error: Failed to launch chrome!
/srv/node_modules/puppeteer/.local-chromium/linux-594312/chrome-linux/chrome: error while loading shared libraries: libXcursor.so.1: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/srv/node_modules/puppeteer/lib/Launcher.js:339:14)
    at Interface.helper.addEventListener (/srv/node_modules/puppeteer/lib/Launcher.js:328:50)
    at emitNone (events.js:111:20)
    at Interface.emit (events.js:208:7)
    at Interface.close (readline.js:370:8)
    at Socket.onend (readline.js:149:10)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)"  
 timestamp:  "2018-10-23T10:58:51.612Z"  
 trace:  "projects/myProject/traces/f6e13e447a34136a46629dc53b6fcddc"  

Additional

I re-created cloud function and re-created project. Sometimes cloud functions return success(launch OK) with puppeteer v1.9.0. But sometimes cloud functions return failed(launch NG) after update cloud functions(index.js, package.json, memory spec, etc).

I'm confused about this issue. This is maybe almost reproducible issue, but sometimes success with same code after re-create the environment.

@guptaluv99
Copy link

Did anyone find the fix for the same, facing the same issue on aws ec2 linux instance

@mbrevda
Copy link
Author

mbrevda commented Oct 24, 2018 via email

@tarasiegel
Copy link

I am experiencing the same issues when using Puppeteer in a Firebase Cloud Function.

I tried changing the Puppeteer version to previous versions as recommended above (1.61, 1.62, 1.7, and 1.8) and redeploying only for it to work intermediately and then not at all if deployed again.

@steren - Is this a file permission issue with Google Cloud Functions + Puppeteer? It looks like Chromium is being added but not accessed.

@steren
Copy link
Contributor

steren commented Oct 25, 2018

The Google Cloud engineering team is investigating.

I performed some tests, and I confirm that the observed behavior is flaky on Cloud Functions:

  • I deployed 1.6.2, it worked
  • I deployed 1.7.0, it fails
  • I redeployed 1.6.2, it failed

I tested on App Engine standard environment (sample), and had no issue running 1.9.0 or 1.7.0

@ncruces
Copy link

ncruces commented Oct 25, 2018

@steren, this seems to be the same issue, then:
https://issuetracker.google.com/issues/118423830

@larrypaul93
Copy link

sometime it worked with google cloud function. i have tried to deploy 3 to 4 time and 4th time it worked with 1.8 version

@jcjones1515
Copy link

I'm also seeing this on deploys to Google Cloud Functions today

@liron-navon
Copy link

I also get it in Firebase cloud functions, here is my log:

Error: Failed to launch chrome!
/srv/node_modules/puppeteer/.local-chromium/linux-575458/chrome-linux/chrome: error while loading shared libraries: libXcursor.so.1: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/srv/node_modules/puppeteer/lib/Launcher.js:285:14)
    at Interface.helper.addEventListener (/srv/node_modules/puppeteer/lib/Launcher.js:274:50)
    at emitNone (events.js:111:20)
    at Interface.emit (events.js:208:7)
    at Interface.close (readline.js:370:8)
    at Socket.onend (readline.js:149:10)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)

@ncruces
Copy link

ncruces commented Oct 26, 2018

Running the following script on GCF:

const exec = require('child_process').execFileSync;
const puppeteer = require('puppeteer');

exports.screenshot = async (req, res) => {
  let output = exec('ldd', [puppeteer.executablePath()], {encoding: 'utf8'});
  res.send(output);
};

The following libs are reported missing:

	libXcursor.so.1 => not found
	libnss3.so => not found
	libnssutil3.so => not found
	libsmime3.so => not found
	libnspr4.so => not found
	libasound.so.2 => not found
	libatk-1.0.so.0 => not found
	libatk-bridge-2.0.so.0 => not found
	libgtk-3.so.0 => not found
	libgdk-3.so.0 => not found

These where in the filesystem in a dump I made a few days ago.

@steren
Copy link
Contributor

steren commented Oct 26, 2018

Thanks for your help reporting and diagnosing the issue.
Our engineering team has identified the root cause and is rolling out a fix today.

@ncruces
Copy link

ncruces commented Oct 26, 2018

Seems to be fixed now, thanks!

@guptaluv99
Copy link

guptaluv99 commented Oct 27, 2018

Am getting this on my console while trying to run the project on aws ec2 with Amazon Linux AMI 2018.03.0.20180811 x86_64 HVM

Please help me as soon as possible. I did npm reinstalled npm puppeteer after @steren last comment, but problem seems to persist. Let me know if am missing something basic.

Error: Failed to launch chrome!
/pathOfProject/node_modules/puppeteer/.local-chromium/linux-594312/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

at onClose (/pathOfProject/node_modules/puppeteer/lib/Launcher.js:339:14)
at Interface.helper.addEventListener (/pathOfProject/node_modules/puppeteer/lib/Launcher.js:328:50)
at emitNone (events.js:111:20)
at Interface.emit (events.js:208:7)
at Interface.close (readline.js:368:8)
at Socket.onend (readline.js:147:10)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)

(node:7422) 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(). (rejection id: 1)

@steren
Copy link
Contributor

steren commented Oct 27, 2018

This issue was for Puppeteer on Cloud Functions, which has now been fixed.
Please open a new one if you are encountering issues on a different platform. The root cause will not be the same.

@paambaati
Copy link

@steren Mind sharing the fix?

@steren
Copy link
Contributor

steren commented Oct 27, 2018

Re-deploy your function and you should be good to go (I am not sure broken function are automatically repaired)
The issue was with the Cloud Function base image, it was missing some OS packages in its latest release. This is not something that is in control of users.

@paambaati
Copy link

@steren Thanks. Are these packages part of this project's recommended list?

@steren
Copy link
Contributor

steren commented Oct 27, 2018

These were OS packages from the Cloud Functions' base container image. These are not something users can control.

@ebidel
Copy link
Contributor

ebidel commented Oct 29, 2018

Going to close this as it's been fixed on the cloud-side. They even added tests so hopefully this won't happen again!

As recommended in #3422 (comment), you may have to redeploy your functions.

@manojmilani123
Copy link

@steren How can we redeploy functions?

@vibhorgupta-gh
Copy link

Hi all,
We are facing a similar issue at Public Lab trying to deploy our code to GCF. Here is the issue:
publiclab/image-sequencer#1032

Please head over and take a look. Looks like the same issue people were having here, we're using puppeteer v1.14.0 which fails to launch chrome in a Node 8 runtime.

@kjr247
Copy link

kjr247 commented Aug 20, 2019

running in aws lambda
I got it working, but we had to ramp up the memory and timeout waaaay up. 256 and 1 min 45 seconds.

@bahynt
Copy link

bahynt commented Aug 26, 2019

It is not working for me, i am using Lambda too, but the error still there. How do you pass this @kjr247 ?

I already tried with 3Gb RAM and timeout to be 5 mins.

error while loading shared libraries: libnss3.so:

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