adieuadieu / serverless-chrome

🌐 Run headless Chrome/Chromium on AWS Lambda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: spawn /var/task/node_modules/@serverless-chrome/lambda/dist/headless-chromium EACCES

R-Studios opened this issue · comments

Headless Chrome running on AWS Lambda with Google lighthouse

Thank you for your detailed blog post about headless Chrome running on AWS Lambda.
https://medium.com/@marco.luethy/running-headless-chrome-on-aws-lambda-fa82ad33a9eb

I would like to use your 'serverless-chrome' npm package to run Google lighthouse on a Lambda instance.
Locally it's working perfectly, but after deploying I get the following error, when I call my Lambda function:

{
    "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:267:19)",
        "    at onErrorNT (internal/child_process.js:469:16)",
        "    at processTicksAndRejections (internal/process/task_queues.js:84:21)"
    ]
}

According to the AWS docs, this problem occurs when files don't have the required permissions set.
https://aws.amazon.com/premiumsupport/knowledge-center/lambda-deployment-package-errors/

'Issues with incorrect permissions are common for packages generated by continuous integration applications. If the security permissions set for your Lambda deployment package .zip or .jar file are incorrect, you get an error when you try to upload the file. Lambda requires global read permissions on code files and any dependent libraries in your deployment package.'

I'm not working on Linux, so I can't try the suggested fix. If you have a solution for this, please let me know.

I'm getting the same issue trying to test out of the box deployment of the screenshot function:

START RequestId: f01104e1-139a-4b1f-b0c1-235eef71ff0b Version: $LATEST
2021-03-05T08:48:35.612Z	f01104e1-139a-4b1f-b0c1-235eef71ff0b	ERROR	Uncaught Exception 	{"errorType":"Error","errorMessage":"spawn /var/task/headless-chromium EACCES","code":"EACCES","errno":"EACCES","syscall":"spawn /var/task/headless-chromium","path":"/var/task/headless-chromium","spawnargs":["--disable-dev-shm-usage","--disable-gpu","--single-process","--no-zygote","--no-sandbox","--remote-debugging-port=9222","--user-data-dir=/tmp/chrome.3pzVLpO","--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/headless-chromium EACCES","    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)","    at onErrorNT (internal/child_process.js:470:16)","    at processTicksAndRejections (internal/process/task_queues.js:84:21)"]}
END RequestId: f01104e1-139a-4b1f-b0c1-235eef71ff0b
REPORT RequestId: f01104e1-139a-4b1f-b0c1-235eef71ff0b	Duration: 32.13 ms	Billed Duration: 33 ms	Memory Size: 1536 MB	Max Memory Used: 20 MB	
Unknown application error occurred