chromium: [BUG] /tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

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();

About this issue

  • Original URL
  • State: open
  • Created 3 months ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

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.