Skip to content
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] /tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory #254

Open
pranavburnwal opened this issue Apr 4, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@pranavburnwal
Copy link

I am using the AWS layer method.
Already checked all existing issues for similarity.
Please see the screenshot below for more debugging and details.
getAllFilesAndFolders gets all files and prints them in an array.

Environment

  • chromium Version: 122.0.0
  • puppeteer / puppeteer-core Version: 22.5.0
  • Node.js Version: 18.x
  • Lambda / GCF Runtime: nodejs18.x

FYI Previously has tried: chromium:118.0 / puppeteer:21.4 - Same issue
My codebase is serverless typescript, which gets compiled by webpack and deployed.

Expected Behavior

Code should just run.

Current Behavior

Screenshot 2024-04-04 at 9 29 28 PM

Steps to Reproduce

			console.log("AWS_EXECUTION_ENV: "+process.env.AWS_EXECUTION_ENV)
            console.log('defaultPuppeteerTest> before ')
            console.log(await getAllFilesAndFolders('/tmp'));
            console.log(await getAllFilesAndFolders('/opt/nodejs/node_modules/@sparticuz/chromium'));
            chromium.setHeadlessMode = true;
            chromium.setGraphicsMode = false
            const executablePath = config.ENVIRONMENT === 'dev'
                ? config.CHROMIUM
                : await chromium.executablePath("/opt/nodejs/node_modules/@sparticuz/chromium/bin");
            
            console.log('defaultPuppeteerTest> after executablePath')
            console.log(await getAllFilesAndFolders('/tmp'));
            console.log(await getAllFilesAndFolders('/opt/nodejs/node_modules/@sparticuz/chromium'));
            let browser = await puppeteer.launch({
                args: config.ENVIRONMENT === 'dev' ? puppeteer.defaultArgs() : ['--disable-extensions', ...chromium.args],
                executablePath: executablePath,
                defaultViewport: {
                    width: 3839,
                    height: 2160,
                    deviceScaleFactor: 2
                },
                env: {
                    TZ: "Asia/Singapore",
                },

                ignoreHTTPSErrors: true,
            });
            const page = await browser.newPage();
            await page.goto("https://example.com");
            const pageTitle = await page.title();
            await browser.close();
@pranavburnwal pranavburnwal added the bug Something isn't working label Apr 4, 2024
@Sparticuz
Copy link
Owner

aws.tar is old (<=120). I would bet your Lambda layer isn't 122 like you think it is. You should have al.tar.br and al2023.tar.br

@pranavburnwal
Copy link
Author

pranavburnwal commented Apr 5, 2024

FYI Previously has tried: chromium:118.0 / puppeteer:21.4 - Same issue

@Sparticuz Yes, the screenshot is for this (above) version I mentioned.

I had tried the same with the given version 122 as well. Here is the screenshot of the same code for reference:
image

Edit: formatting

@pranavburnwal
Copy link
Author

Also tried Method 2 from https://stackoverflow.com/a/72485784
Manually adding PATH and LD_LIBRARY_PATH with /tmp extracted files
Added this in the provider in serverless:

  environment:
    PATH: /var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin:/tmp
    LD_LIBRARY_PATH: /var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib:/tmp/al2/lib

Didnt work.

@Sparticuz
Copy link
Owner

console.log your LD_LIBRARY_PATH, after calling executablePath. Make sure /tmp/al2/lib is in it. The package puts it before all the other entries.

@pranavburnwal
Copy link
Author

console.log your LD_LIBRARY_PATH, after calling executablePath. Make sure /tmp/al2/lib is in it. The package puts it before all the other entries.

It's there, still throws the same error. Super weird.
@Sparticuz What else can I debug to check?

image

@dmarreco
Copy link

Exactly same issue here. Using Esbuild.

@Sparticuz
Copy link
Owner

Maybe try using chromium-min variant? Otherwise Amazon might have silently updated their images

@noppa
Copy link

noppa commented Apr 19, 2024

We also started facing this today. Puppeteer crashes, and the Chromium logs contain

[ERROR:nss_util.cc(124)] Error initializing NSS without a persistent database: NSS error code: -8023

The breakage seems to come between lambda images nodejs:18.v26 and nodejs:18.v28.
Maybe they have upgraded or done something else to NSS that breaks it? They have a open issue about a NSS-related CVE.

@hudsontavares
Copy link

@noppa - yes, they updated Node JS version yesterday

@james-certn
Copy link

We noticed this as well, we had to turn off Auto mode for Lambda runtime upgrades and pin to nodejs:18.v26. I assume something changed with regards to the underlying Amazon Linux image that's used to build the nodejs runtime, like the shared library is renamed or not installed.

What is the realistic path forward, I'm curious?

@Sparticuz
Copy link
Owner

Should just need to boot up the corresponding image on ec2 and grab the updated libs

@noppa
Copy link

noppa commented Apr 20, 2024

Rebuilding the layer with the latest version (123.0.1) of @sparticuz/chromium fixed the issue for us. We were using version 117 before.

Plus we had to re-enable setGraphicsMode due to #247, which seems to make things a bit slower. But oh well, at least it works.

@Sparticuz
Copy link
Owner

Rebuilding the layer with the latest version of this lib fixed the issue for us (we were using 117 before).

Thank you for checking! I will push a fix soon.

@Sparticuz
Copy link
Owner

Can someone try this? I've updated the libnss3.so and libsoftokn3.so files. Github won't allow .br attachements, so please REMOVE .zip from the file.

al2.tar.br.zip

@JonnyBurger
Copy link

We also started facing this today. Puppeteer crashes, and the Chromium logs contain

[ERROR:nss_util.cc(124)] Error initializing NSS without a persistent database: NSS error code: -8023

We don't use this package, but might be helpful nonetheless - this error can occur if libfreeblpriv3.so or libfreebl3.so are missing on the system.

@drew-talon
Copy link

@Sparticuz On Friday I tried your al2.tar.br file and it did not work for me. However I will note that I had many other issues on my end so it may have resolved some but not others. The fix for me was to roll back to nodejs 18.26 from 18.28.
Thank you for all the hard work you do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants