-
-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Failed to launch the browser process: error while loading shared libraries: libnss3.so: cannot open shared object file #164
Comments
@pmakkar93 With Node 12 the Lambda environment needs provisioning of additional shared libraries for Chromium to work, the earliest version that would work on this environment is precisely 3.0.4 (I advise you to upgrade to the latest 5.3.x though). I think the issue that you're facing might be caused by a warm Lambda that is still keeping the files under Edit: I just noticed that you're trying this on Mac? If so please check this wiki page. |
@alixaxel Any potential workaround for this? I also have this exact same problem but since 2.0.0, Puppeteer introduced a change that broke clipping beyond the viewport and this was needed to curve a lot of issues with the screenshotting mechanism. |
I'm getting this same issue with:
|
It's not the exactly same case but I've seen same issue to initialize the browser object, missing libnss3.so. In my case it only happens when I run the lambda with aws-sam-cli in debug mode. Actually I could notice that the environment variable
Also, I know there are few lines which use |
I get the same error, but not related to AWS, but Linux on a Windows 10 machine using WSL 2 (Ubuntu 20.04.1 LTS) and Puppetter: 5.5.0: Solved it by installing all missing dependencies listed here: Puppeteer Troubleshooting |
This may be helpful to some, to check which libs are missing just do |
I just pushed up my code to AWS Lambda, and I'm getting the exact same error. New deployment (actually never been deployed before), NodeJs12, using the shelfio layer. Also got the same error following the instructions in the Lambda Layers option. The resulting zip file, pushed up to AWS Lambda, triggers the same error, missing libnss3.so . |
Here is how I fixed mine.
sudo apt-get update
cd /project_folder/node_modules/puppeteer/.local-chromium/[linux-579032]/[chrome-linux] but replace the bracketed directories with the directories available in your node_modules folder. There you should find the local installation of chrome and from there you ran the next command.
ldd chrome | grep not on a Linux machine to check which dependencies are missing.
sudo apt-get install libpangocairo-1.0-0 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libgconf2-4 libasound2 libatk1.0-0 libgtk-3-0 sudo apt-get install -y libgbm-dev
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox'] }); That is it. You are good to go. Hopefully, this helps someone. 😄 |
@damisparks I have the same problem of running Puppeteer in AWS Lambda env. Lambda cannot run |
@markb-trustifi This issue is now a bit all over the place to be able to understand it and follow up on it properly. I suggest you create a new issue with code to repro it, if that's not possible try passing Chances are, that if there's a missing shared library, it will be logged there. |
I had this error and the fix was to set lambda memory to 512 mb. |
This resulted in an error:
All the other packages installed correctly. This fails:
However, I was able to install it by using apt instead of apt-get:
Once I did that puppeteer works correctly. |
There was a long list of dependencies, so I tried this and it worked:
I am using Ubuntu WSL on Windows 10. |
Has anybody found a solution to this for AWS Lambda? Obviously the lib can't be installed manually to the machine. |
Anecdotally, I am seeing this only on the node16 runtime. When I use the node14 runtime it works fine, and when I bump to node16 I get the
error |
Same here. I was trying to attempt upgrading lambda version after this update aws/aws-lambda-base-images#14 but I got the error above. It was working with v14 with the workaround mentioned in #268 |
@skilbjo FWIW I was able to fix the issue by using the forked package by @Sparticuz in #264 |
hey @tomoima525 , thanks for the heads up! my workflow: are you saying this works? ? |
That layer is currently out of date. You can build your own up to date layer using my fork though |
I didn't noticed that my serverless.yml was on runtime: nodejs16.x. When I changed it to nodejs14.x I was able to run withou this error on aws lambda. |
@johntravolta1 This repo's version only supports node14, not node16. You can support node16 by running the patch found in #274 |
version 6.0.0 + node14 worked for me and under limit |
same issue. anyone solved? |
I faced the same issue on AWS Lambda using Node 16.x. I did the following:
Hope this helps! |
Not really - we need Node 16.x for CDK. |
Error: Failed to launch the browser process! node version - 16x Facing the issue. |
I'm facing the same issue here. Anyone got it working in 2024? I'm also running it in google cloud functions, is there any better way to run this script? |
Check out my fork @Sparticuz/chromium |
@Sparticuz I've used @Sparticuz/chromium I've tried using it with AWS lambda and node 16.x, also using lambda layers, but it doesn't work (it does locally with public.ecr.aws/lambda/nodejs:18 docker) |
That means that the AL tar isn't being extracted, which means that the environment you are using doesn't have the standard AWS environment variables |
@Sparticuz Thanks for the info, I've tried using AWS lambda layers also, the AL tar is in the zip file, do you see any reason why isn't being extracted, I'm executing it in AWS lambda, so it has to have the necessary envs I think? Added an issue also: Sparticuz/chromium#285 On my local machine with public.ecr.aws/lambda/nodejs:18 docker image it does work as expected |
Anyone facing this issue within AWS Lambda, Here's how you can fix the issue : Just check the pull request here made by @Sparticuz : You have to basically edit this file in your node_modules directory :
Search for this line :
and replace this line with your nodejs version in OR regex block like this : (example runtime 16 taken)
There will be 2 places of the same line you need to replace. Then just upload your package to AWS Lambda and you will be good to go. Hope this helps ! |
Downgrading to lambda Runtime: Node.js 14.x and memory 512mb worked for me |
The issue still exist btw I'm thinking of switching to EC2 instead of Lambda |
Environment
chrome-aws-lambda
Version: 3.0.4puppeteer
/puppeteer-core
Version: 3.0.4Expected Behavior
Chrome should have load.
Current Behavior
Error: Failed to launch the browser process!
/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/var/task/node_modules/puppeteer-core/lib/Launcher.js:547:20)
at Interface. (/var/task/node_modules/puppeteer-core/lib/Launcher.js:537:65)
at Interface.emit (events.js:327:22)
at Interface.EventEmitter.emit (domain.js:483:12)
at Interface.close (readline.js:416:8)
at Socket.onend (readline.js:194:10)
at Socket.emit (events.js:327:22)
at Socket.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Steps to Reproduce
Previously my code was running properly on nodejs8.10 supported AWS Lambda function but after forcefully upgrade to nodejs12.x, my code starts to throw this error. I tried upgrading chrome-aws-lambda and puppeteer-core version to 2.1.1 and even the latest 5.3.1 but no luck on resolving the issue.
The text was updated successfully, but these errors were encountered: