Fail to start chromium on AWS with 1.0.0-57.2
See original GitHub issueHi,
I can’t start chromium on AWS Lambda. It seems, the shipped chromium version is not statically compiled with libnss3.so
.
Used code:
const launchChrome = require('@serverless-chrome/lambda');
const request = require('superagent');
module.exports.getChrome = async () => {
const chrome = await launchChrome({
flags: ['--no-sandbox', '--headless']
});
const response = await request
.get(`${chrome.url}/json/version`)
.set('Content-Type', 'application/json');
const endpoint = response.body.webSocketDebuggerUrl;
return {
endpoint,
instance: chrome,
};
};
Logs under AWS:
INFO @serverless-chrome/lambda: Spawning headless shell
INFO @serverless-chrome/lambda: ChromeLauncher No debugging port found on port 9222, launching a new Chrome.
INFO @serverless-chrome/lambda: Launcher Chrome running with pid 25 on port 9222.
INFO @serverless-chrome/lambda: Waiting for Chrome 0
INFO @serverless-chrome/lambda: Waiting for Chrome 1
...
INFO @serverless-chrome/lambda: Waiting for Chrome 10
INFO @serverless-chrome/lambda: Error trying to spawn chrome: Error: connect ECONNREFUSED 127.0.0.1:9222
INFO @serverless-chrome/lambda: stderr log: /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
Environement:
- NodeJS 12
@serverless-chrome/lambda
: 1.0.0-57.2
Best,
EM
Issue Analytics
- State:
- Created 3 years ago
- Reactions:20
- Comments:5
Top Results From Across the Web
1143503 - Chromium crashes on AWS Lambda - Monorail
We start a selenium test inside aws lambda ... We are getting the "chrome not reachable" exception, and then the test fails.
Read more >Runtime versions using Node.js and Puppeteer
Explains the versions of canary runtimes, libraries, and configuration information.
Read more >Failed to launch chromium headless using puppeteer on ...
Puppeteer Error: Chromium revision is not downloaded - This link helped me to debug that I need to run install.js in puppeteer manually....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can find all the required info here: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-image.html
my Dockerfile is derived from the AWS documentation:
The builder step just builds the nodejs app, nothing special there. And as you can see, I’m then installing
chromium
directly from alpine repositories, as I was able to test locally, that it works in headless correctly.In the app itself, I’m still using
serverless
, but I’ve removed the dependency on this package, as it’s not needed anymore and I can just start the chromium in headless directly and can get rid of a bunch of the workarounds for Amazon Linux. But it was a pain in the butt to get it working smoothly, not gonna lie.I’ve solved it by using a custom docker image for lambda 🤷