Skip to content

[BUG] Failed to launch the browser process: error while loading shared libraries: libnss3.so: cannot open shared object file #164

Closed
@pmakkar93

Description

@pmakkar93

Environment

  • chrome-aws-lambda Version: 3.0.4
  • puppeteer / puppeteer-core Version: 3.0.4
  • OS: Mac
  • Node.js Version: 12.x
  • Lambda / GCF Runtime: nodejs12.x

Expected 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

const chromium = require('chrome-aws-lambda');
const puppeteer = require('puppeteer-core');

  async convertToPdf(request) {
    try {
      console.log('Starting puppeteer browser.');

      const browser = await chromium.puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: true,
        ignoreHTTPSErrors: true
      });

      console.log('Puppeteer launched: ' + !!browser);


      if (request.sections.length > 75) {
        throw new Error('Only 75 report sections are allowed');
      }

      let pdfs = await Promise.all(_.map(request.sections, async (section, $index) => {
        if (section.s3Pdf) {
          let s3Response = await s3.getObject({
            Bucket: section.s3Pdf.bucket,
            Key: section.s3Pdf.key
          }).promise();

          console.log(`PDF ${$index} retrieved successfully`);
          return s3Response.Body;
        }
        const page = await browser.newPage();

        page.setViewport(request.viewPort || {
          width: 1024,
          height: 600
        });

        section.options = section.options || {};

        console.log(`Loading section ${$index}...`);
        await page.setContent(this.fromBase64(section.html), {waitUntil: ['networkidle0']});
        console.log(`Section ${$index} Load complete. Converting html to pdf using puppeteer. Options: ${JSON.stringify(section.options)}`);

        let body = await page.pdf(_.assign({format: 'letter'}, section.options));

        console.log(`PDF ${$index} created successfully`);
        page.close();
        return body;
      }));

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginvalidThis doesn't seem right

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions