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.

[BUG] Failed to launch chrome

See original GitHub issue

Environment

  • chrome-aws-lambda :2
  • puppeteer / puppeteer-core :2
  • OS: osx docker lambda working but lambda runtime node12.x not working
  • Node.js Version:12
  • Lambda / GCF Runtime:Lambda

Expected Behavior

It should work.

Current Behavior

Lambda response

{
  "errorMessage": "Failed to launch chrome!\n\n\nTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md\n",
  "errorType": "Error",
  "stackTrace": [
    "",
    "",
    "TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md",
    "",
    "onClose (/var/task/node_modules/puppeteer-core/lib/Launcher.js:348:14)",
    "Interface.helper.addEventListener (/var/task/node_modules/puppeteer-core/lib/Launcher.js:337:50)",
    "emitNone (events.js:111:20)",
    "Interface.emit (events.js:208:7)",
    "Interface.close (readline.js:370:8)",
    "Socket.onend (readline.js:149:10)",
    "emitNone (events.js:111:20)",
    "Socket.emit (events.js:208:7)",
    "endReadableNT (_stream_readable.js:1064:12)",
    "_combinedTickCallback (internal/process/next_tick.js:138:11)"
  ]
}

Steps to Reproduce

1- save to index.js

const chromium = require('chrome-aws-lambda');

exports.handler = async (event, context) => {
	let result = null;
	let browser = null;

	try {
		browser = await chromium.puppeteer.launch({
			args: chromium.args,
			defaultViewport: chromium.defaultViewport,
			executablePath: await chromium.executablePath,
			headless: chromium.headless,
		});

		let page = await browser.newPage();

		await page.goto(event.url || "https://github.com");

		title = await page.title();
        } catch (error) {
		return context.fail(error);
	} finally {
		if (browser !== null) {
			await browser.close();
		}
	}

	return context.succeed(title)
};

2- npm install puppeteer-core chrome-aws-lambda --save-prod 3- create zip and deploy lambda with runtime node12.x. occur this error.

Thanks,

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:32 (7 by maintainers)

github_iconTop GitHub Comments

13reactions
Gregjarvezcommented, Dec 13, 2019
  const browser = await puppeteerExtra.launch({
     headless: chromium.headless,
     ignoreHTTPSErrors: true,
    executablePath:
      process.env.NODE_ENV !== 'production'
        ? undefined
        : await chromium.executablePath,
    defaultViewport: chromium.defaultViewport,
    args: chromium.args,
  });

I got this to work by only using await chromium.executablePath in prod as I know this issue has been resolved in cloud functions. I am not exactly sure why this works and didn’t have the time to look into it but it does.

6reactions
exentrichcommented, Dec 9, 2019

Fail when run locally without API Gateway (I’m using serverless framework). With serverless + serverless_offline plugin works as expected!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug]: Failed to launch chrome · Issue #9029 - GitHub
Steps to reproduce the problem: ./node_modules/puppeteer/.local-chromium/linux-1036745/chrome-linux/chrome -v --no-sandbox --disable ...
Read more >
Fix Chrome if it crashes or won't open - Computer
First: Try these common Chrome crash fixes · Close every tab except for the one that's showing the error message. · Quit other...
Read more >
Unable to launch chrome-42 in CentOS-6 - Google Groups
After updating Chrome to 42 version (on CentOS 6.6 ), i was unable to launch the chrome. It is simply dumping core. Filed...
Read more >
unable to launch chrome : Conflict with System Mechanics ...
Issue 65 : unable to launch chrome : Conflict with System Mechanics Professional · 1. download ChromeSetup.exe · 2. execute ChromeSetup.exe and wait...
Read more >
Troubleshooting - Puppeteer
Chrome is downloaded but fails to launch on Node.js 14​ ... The bug was fixed in Node.js v14.1.0, so please make sure you're...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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