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
chromiumVersion: 122.0.0puppeteer/puppeteer-coreVersion: 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
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: closed
- Created 3 years ago
- Reactions: 2
- Comments: 19 (7 by maintainers)
The reasons for this error are well known at this point so I’m going to close out this ticket. Please open a new issue if you need a new environment added.
I also ran into libnss3.so related error. In case someone is still facing this issue, I have successfully achieved HTML to image conversion within AWS Lambda using the following versions:
@sparticuz/chromium:132.0.0puppeteer-core:22.11.2The Lambda function should run on
Architecture.X86_64. I used theNODEJS_22_Xruntime and thenode:23-slimDocker image.Rebuilding the layer with the latest version (123.0.1) of
@sparticuz/chromiumfixed the issue for us. We were using version 117 before.Plus we had to re-enable
setGraphicsModedue to #247, which seems to make things a bit slower. But oh well, at least it works.Should just need to boot up the corresponding image on ec2 and grab the updated libs