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 #93

Closed
saurabh147sharma opened this issue Jan 18, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@saurabh147sharma
Copy link

saurabh147sharma commented Jan 18, 2020

Environment

  • chrome-aws-lambda Version: 2.0.2
  • puppeteer / puppeteer-core Version: 1.20.0
  • OS: I'm using this feature at AWS Batch
  • Node.js Version: 12.x
  • Lambda / GCF Runtime: 12.x

Expected Behavior

It should work.

Current Behavior

[ Error: Failed to launch chrome!
  /tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
  
  TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
  
      at onClose (/node_modules/puppeteer-core/lib/Launcher.js:348:14)
      at Interface.helper.addEventListener (/node_modules/puppeteer-core/lib/Launcher.js:337:50)
      at Interface.emit (events.js:203:15)
      at Interface.EventEmitter.emit (domain.js:448:20)
      at Interface.close (readline.js:397:8)
      at Socket.onend (readline.js:173:10)
      at Socket.emit (events.js:203:15)
      at Socket.EventEmitter.emit (domain.js:448:20)
      at endReadableNT (_stream_readable.js:1143:12)
      at process._tickCallback (internal/process/next_tick.js:63:19),

Steps to Reproduce

While submitting the job I use the below environment:

containerOverrides: { environment: [ { name: 'AWS_LAMBDA_FUNCTION_NAME', value: 'Lambda_Function_Name' }, { name: 'AWS_EXECUTION_ENV', value: 'AWS_Lambda_nodejs12.x' } ] }

I also tried to add below in the environment but same error:
{ name: 'FONTCONFIG_PATH', value: undefined }, { name: 'LD_LIBRARY_PATH', value: '/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib' }

layer + lambda both have runtime nodejs12.x

@saurabh147sharma saurabh147sharma added the bug Something isn't working label Jan 18, 2020
@alixaxel
Copy link
Owner

@saurabh147sharma I'm new to AWS Batch, could you share some sort of repro with me?

Also from what I read, AWS Batch doesn't interoperate with AWS Lambda?

@saurabh147sharma
Copy link
Author

saurabh147sharma commented Jan 18, 2020

@alixaxel I used chrome-aws-lambda package to generate the PDFs at AWS lambda and it was working fine but now I need to generate a large number of PDFs so moved the same code to AWS Batch and changed the starting point as it was a handler function when I was running lambda.
Code is exactly the same but giving errors:
browser = await chromium.puppeteer.launch({ args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: chromium.headless }); const page = await browser.newPage();

For interoperation, I think AWS Batch interoperate with AWS lambda because while submitting a job If I remove the following environment variables
containerOverrides: { environment: [ { name: 'AWS_LAMBDA_FUNCTION_NAME', value: 'Lambda_Function_Name' }, { name: 'AWS_EXECUTION_ENV', value: 'AWS_Lambda_nodejs12.x' } ] }
It gives an error "chromium revision is not downloaded" or if I added this environment variables it gives me libnss3.so error.

@saurabh147sharma
Copy link
Author

saurabh147sharma commented Jan 19, 2020

@alixaxel I have fixed the issue by using the puppeteer library. I just run the below command:
apt-get update \ # Install latest chrome dev package, which installs the necessary libs to # make the bundled version of Chromium that Puppeteer installs work. && apt-get install -y wget --no-install-recommends \ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ && apt-get update \ && apt-get install -y google-chrome-unstable --no-install-recommends \ && rm -rf /var/lib/apt/lists/* \ && wget --quiet https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O /usr/sbin/wait-for-it.sh \ && chmod +x /usr/sbin/wait-for-it.sh

I'm closing the bug.
Thanks, this is a great NPM module to run the puppeteer at AWS lambda.
Cheers!!!

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

2 participants