Example code:
https://github.com/elie222/examples-1/tree/fix/aws-node-puppeteer-local/aws-node-puppeteer
This works locally:
serverless offline
# Then go to: http://localhost:3000/?url=https://google.com
But running:
serverless deploy
# Then go to: https://lambdaurl/?url=https://google.com
Gives this error:
{
"message": "Internal server error"
}
And in the CloudWatch logs:
{
"errorType": "Error",
"errorMessage": "Unable to start Chrome. If you have the DEBUG env variable set,there will be more in the logs.",
"stack": [
"Error: Unable to start Chrome. If you have the DEBUG env variable set,there will be more in the logs.",
" at /var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:376:13",
" at Generator.throw (<anonymous>)",
" at step (/var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:311:193)",
" at /var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:311:404",
" at processTicksAndRejections (internal/process/task_queues.js:93:5)"
]
}
Hi @elie222,
Did you find the cause of it? The same thing is happening to me too.
I gave up on it in the end. Was just playing around and didn't have the time/energy to get to the bottom of it 😢
Best,
Eliezer
On Fri, Feb 14, 2020 at 11:59 AM, Zolo < [email protected] > wrote:
Hi @ elie222 ( https://github.com/elie222 ) ,
Did you find the cause of it? The same thing is happening to me too.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (
https://github.com/adieuadieu/serverless-chrome/issues/251?email_source=notifications&email_token=AAXSQXY2XLJ2OB7D6AOCFSLRCZTRLA5CNFSM4KPLOSMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELYIDWQ#issuecomment-586187226
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AAXSQX2SH3QGRK26E45YA73RCZTRLANCNFSM4KPLOSMA
).
Same happens to me, and no solution yet :(
Downgraded the runtime from nodejs12.x to nodejs8.10. Got this error instead:
(node:1) UnhandledPromiseRejectionWarning: Error: spawn EACCES
at _errnoException (util.js:1022:11)
at ChildProcess.spawn (internal/child_process.js:323:11)
at Object.exports.spawn (child_process.js:502:9)
at /var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:199:40
at Generator.next (<anonymous>)
at step (/var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:69:193)
at /var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:69:439
at new Promise (<anonymous>)
at /var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:69:101
at Promise (/var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:220:23)
After hours of frustration, used https://github.com/alixaxel/chrome-aws-lambda and it worked without an issue!
Yea, Same thing is happening to me and AWS does not support nodejs8.10 anymore. I can not seem to get my function to work with AWS. I may have to start over with GCP function or switch over and try the 'chrome-aws-lambda' package.
It's strange because my function works with serverless offline and I get the data I need when I make the postman call to my localhost. However, once I deploy it, I get this error and I have not a clue how to fix it.
`
2020-06-05T12:54:59.398-04:00 | 2020-06-05T16:54:59.398Z 3bca2ce3-63c9-46ae-ba78-f1e0638b8eaf ERROR Error occured in serverless-plugin-chrome wrapper when trying to ensure Chrome for handler() handler. { flags: [] } Error: Unable to start Chrome. If you have the DEBUG env variable set,there will be more in the logs. at /var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:376:13 at Generator.throw (
-- | --
 | 2020-06-05T12:54:59.398-04:00 | 2020-06-05T16:54:59.398Z 3bca2ce3-63c9-46ae-ba78-f1e0638b8eaf ERROR Invoke Error { "errorType": "Error", "errorMessage": "Unable to start Chrome. If you have the DEBUG env variable set,there will be more in the logs.", "stack": [ "Error: Unable to start Chrome. If you have the DEBUG env variable set,there will be more in the logs.", " at /var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:376:13", " at Generator.throw (
`
Any advice is much appreciated. I can show the code as well or link to my Github repo if needed.
After hours of frustration, used
https://github.com/alixaxel/chrome-aws-lambdaand it worked without an issue!
@zolbayars I ended up doing this and it worked! Thank you!
I tried to tackle this issue for couple of days. Didn't succeed but I think I can show a way if anybody wants to continue.
Basically the problem is that Chrome bundled with serverless-chrome-plugin is over two years old and in not working on current Amazon stack.
I think the way to fix this issue is to use this PR to build fresh version of chromium and then replace it in node_modules/@serverless-chrome/lambda/dist.
I tried to tackle this issue for couple of days. Didn't succeed but I think I can show a way if anybody wants to continue.
Basically the problem is that Chrome bundled with
serverless-chrome-pluginis over two years old and in not working on current Amazon stack.I think the way to fix this issue is to use this PR to build fresh version of chromium and then replace it in
node_modules/@serverless-chrome/lambda/dist.
The reason why my PR works is because the lambda runtime is continually being updated to newer and newer versions of the Amazon Linux AMI. The dependencies have significantly changed since the most recent release and need some tweaking in order to get right.
Hello @krtek and @skunkworker.
I build a chromium locally fromp this PR, it seems successfull, but I don't find the built chromium ? Do you know in which folder is it ? I'm surely missing something :/
Thanks.
Hello @zes,
use docker images to list available images. One of the images should be named headless-chromium.
Copy its ID and then run following
docker run -dt --rm --name headless-chromium <id>
docker cp headless-chromium:/bin/headless-chromium ./
docker stop headless-chromium
Even after compiling my own chromium and replacing it in node_modules I'm still getting following error at AWS:
2020-06-15T08:03:46.378Z 7e6ea9b0-4a79-4453-a05b-b6dc647188d7 INFO @serverless-chrome/lambda: stderr log: /var/task/headless-chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
Most helpful comment
After hours of frustration, used
https://github.com/alixaxel/chrome-aws-lambdaand it worked without an issue!