Headless Chrome not working on AWS lamda
kumaravel001 opened this issue · 3 comments
Hi I am just stuck with this error while launching headless chrome in AWS lambda. Could someone help me on this
{
"errorType": "Error",
"errorMessage": "spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES",
"trace": [
"Error: spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES",
" at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)",
" at onErrorNT (internal/child_process.js:456:16)",
" at processTicksAndRejections (internal/process/task_queues.js:80:21)"
]
}
Logs
START RequestId: 8a3ffcd4-2d80-48c0-b225-e878b6f50706 Version: $LATEST
2019-12-09T21:48:28.087Z 8a3ffcd4-2d80-48c0-b225-e878b6f50706 ERROR Uncaught Exception {"errorType":"Error","errorMessage":"spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES","code":"EACCES","errno":"EACCES","syscall":"spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium","path":"/var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium","spawnargs":["--disable-dev-shm-usage","--disable-gpu","--single-process","--no-zygote","--no-sandbox","--remote-debugging-port=9222","--user-data-dir=/tmp/chrome.ZlKMe7s","--disable-setuid-sandbox","--disable-dev-shm-usage","--disable-gpu","--single-process","--no-zygote","--no-sandbox","--window-size=1280,1696","--hide-scrollbars","about:blank"],"stack":["Error: spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES"," at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)"," at onErrorNT (internal/child_process.js:456:16)"," at processTicksAndRejections (internal/process/task_queues.js:80:21)"]}END RequestId: 8a3ffcd4-2d80-48c0-b225-e878b6f50706
REPORT RequestId: 8a3ffcd4-2d80-48c0-b225-e878b6f50706
My Code
const launchChrome = require('@serverless-chrome/lambda')
const CDP = require('chrome-remote-interface')
module.exports.handler = function handler (event, context, callback) {
launchChrome({
flags: ['--window-size=1280,1696', '--hide-scrollbars']
})
.then((chrome) => {
console.log("Chrome is now running");
CDP.Version()
.then((versionInfo) => {
callback(null, {
versionInfo,
})
})
.catch((error) => {
callback(error)
})
})
console.log("Chrome didn't launch correctly");
.catch(callback)
}
I've got that same error. Have you resolved this issue?
Locally works fine, after deployment (serverless and lambda, Node.js 10.x) I'm getting this error:
{ "errorType": "Error", "errorMessage": "spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES", "trace": [ "Error: spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES", " at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)", " at onErrorNT (internal/child_process.js:415:16)", " at process._tickCallback (internal/process/next_tick.js:63:19)" ] }
Hey @kumaravel001, @sapcik
This exact error is happening to me. Have you guys found any way to resolve this?
It's working ok on serverless offline
and there was no error while deploying via serverless deploy
. But when I invoke the endpoint, the following is getting logged:
ERROR Uncaught Exception
{
"errorType": "Error",
"errorMessage": "spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES",
"code": "EACCES",
"errno": "EACCES",
"syscall": "spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium",
"path": "/var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium",
"spawnargs": [
"--disable-dev-shm-usage",
"--disable-gpu",
"--single-process",
"--no-zygote",
"--no-sandbox",
"--remote-debugging-port=9222",
"--user-data-dir=/tmp/chrome.z7Op5pm",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-gpu",
"--single-process",
"--no-zygote",
"--no-sandbox",
"about:blank"
],
"stack": [
"Error: spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES",
" at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)",
" at onErrorNT (internal/child_process.js:456:16)",
" at processTicksAndRejections (internal/process/task_queues.js:81:21)"
]
}
Then Unknown application error occurred
I was getting the same error and came across this AWS support article:
https://aws.amazon.com/premiumsupport/knowledge-center/lambda-deployment-package-errors/
This article suggests it is a problem with a permissions issue with the deployment package. I am using windows and so I tried their suggestion of installing the windows subsystem for linux and then once i used serverless deploy through WSL i got past the EACCES error. Unfortunately, I then started to get another error that I couldn't get past and so I decided to abandon serverless-chrome and use this lighthouse-layer:
https://github.com/erezrokah/lighthouse-layer
I followed their directions in the readme and it worked great. If you decide to continue with the serverless-chrome route and want more details about how I solved the EACCES error by installing WSL let me know and I can provide more details.