Deploy problem with "This function has crashed" even though it works locally

I’ve deployed the data to the cloud and the draft URL is https://643580039702f30067aaf912–nemlig-data.netlify.app

Yet, when I hit https://643580039702f30067aaf912--nemlig-data.netlify.app/.netlify/functions/results
I get the following – Screenshot by Lightshot :

This function has crashed
An unhandled error in the function code triggered the following message:

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: Troubleshooting | Puppeteer

Stack trace
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: Troubleshooting | Puppeteer

at Interface.onClose (/var/task/node_modules/@puppeteer/browsers/lib/cjs/launch.js:262:24)
at Interface.emit (node:events:525:35)
at Interface.close (node:readline:590:8)
at Socket.onend (node:readline:280:10)
at Socket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Connection details
Netlify internal ID: 01GXRFVPHAZT1SN22WYTCJP9XG

The better the post - the faster the answer.

I suggest checking out the following forum threads that relate to this issue

Search term libnss3

I have succeeded to develop & deploy to Netlify using Sparticuz/chromium instead of chrome-aws-lambda for Serverless Platforms.

Now the function looks like the following:

const chromium = require("@sparticuz/chromium");
const puppeteer = require('puppeteer-core');

chromium.setHeadlessMode = true; 
chromium.setGraphicsMode = false;

exports.handler = async function (event, context) {
    const browser = await puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: process.env.CHROME_EXECUTABLE_PATH || await chromium.executablePath,
        headless: chromium.headless,
    });

    const page = await browser.newPage();

    await page.goto("https://spacejelly.dev/");  

    const title = await page.title();
    const description = await page.$eval('meta[name="description"]', element => element.content);

    await browser.close();

    return {
        statusCode: 200,
        body: JSON.stringify({
            status: "OK, Done!",
            page: {
                title,
                description
            }
        })
    };
}
1 Like