Lambas function Failed to launch chrome

Hi! First off, thanks for a great platform! I’ve started to try out Netlify FUnctions.
I’ve cloned this repo: https://github.com/netlify-labs/netlify-functions-headless-chrome

It deploys OK, but when I visit my function, it logs the following error:

11:07:34 PM: 2020-05-19T22:07:34.347Z	c561d869-778c-46df-81d4-6dbaef9e7abf	INFO	spawning chrome headless
11:07:36 PM: 2020-05-19T22:07:36.917Z	c561d869-778c-46df-81d4-6dbaef9e7abf	INFO	error Error: Failed to launch chrome!/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directoryTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md    at onClose (/var/task/node_modules/puppeteer-core/lib/Launcher.js:348:14)    at Interface.<anonymous> (/var/task/node_modules/puppeteer-core/lib/Launcher.js:337:50)    at Interface.emit (events.js:322:22)    at Interface.close (readline.js:409:8)    at Socket.onend (readline.js:187:10)    at Socket.emit (events.js:322:22)    at endReadableNT (_stream_readable.js:1187:12)    at processTicksAndRejections (internal/process/task_queues.js:84:21)
11:07:36 PM: Duration: 2574.05 ms	Memory Usage: 391 MB	Init Duration: 295.28 ms	

The site is here: https://5ec45812e1142d00074408bf--eloquent-bose-e5b921.netlify.app
And the function is here: https://5ec45812e1142d00074408bf--eloquent-bose-e5b921.netlify.app/.netlify/functions/chrome/

Here’s the end of the deploy log as I hit the character limit:

11:05:54 PM:   adding: node_modules/minimist/example/ (stored 0%)
11:05:54 PM:   adding: node_modules/minimist/example/parse.js
11:05:54 PM:  (deflated 6%)
11:05:54 PM:   adding: node_modules/minimist/readme.markdown
11:05:54 PM:  (deflated 52%)
11:05:54 PM:   adding: node_modules/minimist/.travis.yml (deflated 30%)
11:05:54 PM:   adding: node_modules/minimist/index.js
11:05:54 PM:  (deflated 76%)
11:05:54 PM:   adding: node_modules/minimist/LICENSE
11:05:54 PM:  (deflated 42%)
11:05:54 PM:   adding: node_modules/minimist/test/
11:05:54 PM:  (stored 0%)
11:05:54 PM:   adding: node_modules/minimist/test/long.js (deflated 70%)
11:05:54 PM:   adding: node_modules/minimist/test/default_bool.js (deflated 72%)
11:05:54 PM:   adding: node_modules/minimist/test/parse_modified.js
11:05:54 PM:  (deflated 31%)
11:05:54 PM:   adding: node_modules/minimist/test/dotted.js
11:05:54 PM:  (deflated 67%)
11:05:54 PM:   adding: node_modules/minimist/test/whitespace.js (deflated 29%)
11:05:54 PM:   adding: node_modules/minimist/test/unknown.js
11:05:54 PM:  (deflated 79%)
11:05:54 PM:   adding: node_modules/minimist/test/proto.js
11:05:54 PM:  (deflated 76%)
11:05:54 PM:   adding: node_modules/minimist/test/num.js (deflated 68%)
11:05:54 PM:   adding: node_modules/minimist/test/parse.js
11:05:54 PM:  (deflated 75%)
11:05:54 PM:   adding: node_modules/minimist/test/dash.js
11:05:54 PM:  (deflated 68%)
11:05:54 PM:   adding: node_modules/minimist/test/all_bool.js
11:05:54 PM:  (deflated 64%)
11:05:54 PM:   adding: node_modules/minimist/test/kv_short.js (deflated 51%)
11:05:54 PM:   adding: node_modules/minimist/test/bool.js
11:05:54 PM:  (deflated 81%)
11:05:54 PM:   adding: node_modules/minimist/test/short.js
11:05:54 PM:  (deflated 75%)
11:05:54 PM:   adding: node_modules/minimist/test/stop_early.js
11:05:54 PM:  (deflated 43%)
11:05:54 PM:   adding: node_modules/minimist/package.json
11:05:54 PM:  (deflated 56%)
11:05:54 PM:   adding: node_modules/safe-buffer/ (stored 0%)
11:05:54 PM:   adding: node_modules/safe-buffer/README.md
11:05:54 PM:  (deflated 65%)
11:05:54 PM:   adding: node_modules/safe-buffer/index.js (deflated 67%)
11:05:54 PM:   adding: node_modules/safe-buffer/LICENSE (deflated 41%)
11:05:54 PM:   adding: node_modules/safe-buffer/package.json (deflated 55%)
11:05:54 PM:   adding: node_modules/safe-buffer/index.d.ts (deflated 79%)
11:05:54 PM:   adding: node_modules/fs.realpath/ (stored 0%)
11:05:54 PM:   adding: node_modules/fs.realpath/README.md (deflated 47%)
11:05:54 PM:   adding: node_modules/fs.realpath/index.js (deflated 67%)
11:05:54 PM:   adding: node_modules/fs.realpath/LICENSE (deflated 50%)
11:05:54 PM:   adding: node_modules/fs.realpath/package.json (deflated 56%)
11:05:54 PM:   adding: node_modules/fs.realpath/old.js (deflated 68%)
11:05:54 PM:   adding: node_modules/pend/ (stored 0%)
11:05:54 PM:   adding: node_modules/pend/README.md (deflated 61%)
11:05:54 PM:   adding: node_modules/pend/index.js (deflated 62%)
11:05:54 PM:   adding: node_modules/pend/LICENSE (deflated 41%)
11:05:54 PM:   adding: node_modules/pend/test.js (deflated 76%)
11:05:54 PM:   adding: node_modules/pend/package.json (deflated 53%)
11:05:54 PM:   adding: package-lock.json (deflated 71%)
11:05:54 PM:   adding: package.json (deflated 39%)
11:05:54 PM: > headless-chrome-netlify-functions@0.1.0 postzip /opt/build/repo
11:05:54 PM: > mv functions/chrome/chrome.zip functions-build
11:05:54 PM: > headless-chrome-netlify-functions@0.1.0 build /opt/build/repo
11:05:54 PM: > react-scripts build
11:05:55 PM: Creating an optimized production build...
11:06:03 PM: Compiled successfully.
11:06:03 PM: File sizes after gzip:
11:06:03 PM:   39.9 KB  build/static/js/2.f235d0d3.chunk.js
11:06:03 PM:   792 B    build/static/js/runtime-main.bb063ad9.js
11:06:03 PM:   562 B    build/static/js/main.5220fb8f.chunk.js
11:06:03 PM:   305 B    build/static/css/main.4b738920.chunk.css
11:06:03 PM: The project was built assuming it is hosted at /.
11:06:03 PM: You can control this with the homepage field in your package.json.
11:06:03 PM: The build folder is ready to be deployed.
11:06:03 PM: You may serve it with a static server:
11:06:03 PM:   npm install -g serve
11:06:03 PM:   serve -s build
11:06:03 PM: Find out more about deployment here:
11:06:03 PM:   bit.ly/CRA-deploy
11:06:04 PM: Function Dir: /opt/build/repo/functions-build
11:06:04 PM: TempDir: /tmp/zisi-5ec45812e1142d00074408bf
11:06:04 PM: Prepping functions with zip-it-and-ship-it 0.3.1
11:06:04 PM: [ { path: '/tmp/zisi-5ec45812e1142d00074408bf/chrome.zip',
11:06:04 PM:     runtime: 'js' } ]
11:06:04 PM: Prepping functions complete
11:06:04 PM: Caching artifacts
11:06:04 PM: Started saving node modules
11:06:04 PM: Finished saving node modules
11:06:04 PM: Started saving pip cache
11:06:05 PM: Finished saving pip cache
11:06:05 PM: Started saving emacs cask dependencies
11:06:05 PM: Finished saving emacs cask dependencies
11:06:05 PM: Started saving maven dependencies
11:06:05 PM: Finished saving maven dependencies
11:06:05 PM: Started saving boot dependencies
11:06:05 PM: Finished saving boot dependencies
11:06:05 PM: Started saving go dependencies
11:06:05 PM: Finished saving go dependencies
11:06:05 PM: Build script success
11:06:05 PM: Starting to deploy site from 'build'
11:06:05 PM: Creating deploy tree 
11:06:05 PM: Creating deploy upload records
11:06:05 PM: 0 new files to upload
11:06:05 PM: 1 new functions to upload
11:06:11 PM: Starting post processing
11:06:11 PM: Post processing done
11:06:11 PM: Site is live
11:06:32 PM: Finished processing build request in 1m24.205204924s

Thanks in advance!
Matt

Hi, thanks for a great platform.

I cloned this repo: https://github.com/netlify-labs/netlify-functions-headless-chrome
Which deploys OK, but when I visit the function, it logs an error:

11:07:34 PM: 2020-05-19T22:07:34.347Z	c561d869-778c-46df-81d4-6dbaef9e7abf	INFO	spawning chrome headless
11:07:36 PM: 2020-05-19T22:07:36.917Z	c561d869-778c-46df-81d4-6dbaef9e7abf	INFO	error 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 (/var/task/node_modules/puppeteer-core/lib/Launcher.js:348:14)
    at Interface.<anonymous> (/var/task/node_modules/puppeteer-core/lib/Launcher.js:337:50)
    at Interface.emit (events.js:322:22)
    at Interface.close (readline.js:409:8)
    at Socket.onend (readline.js:187:10)
    at Socket.emit (events.js:322:22)
    at endReadableNT (_stream_readable.js:1187:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
11:07:36 PM: Duration: 2574.05 ms	Memory Usage: 391 MB	Init Duration: 295.28 ms	
11:19:42 PM: 2020-05-19T22:19:42.034Z	11472b22-5652-4f6f-98dc-658731be5146	INFO	spawning chrome headless
11:19:43 PM: 2020-05-19T22:19:43.090Z	2555e0b1-f0c0-4ebf-80fd-7e5a028c6727	INFO	spawning chrome headless
11:19:44 PM: 2020-05-19T22:19:44.751Z	11472b22-5652-4f6f-98dc-658731be5146	INFO	error Error: Failed to launch chrome!
/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

The site URL is: https://eloquent-bose-e5b921.netlify.app/
The function URL is: https://eloquent-bose-e5b921.netlify.app/.netlify/functions/chrome

Thanks in advance!
Matt

Hey @Matt,

Looks like this has been covered before. It seems like you need to update your package.json!

@mattnicholson I don’t think it’ll help you; there appears to be a 10 second limit on Netlify functions and invoking Puppeteer typically exceeds it. I’ve deployed the same example app you have and found the same thing.

Unfortunately, I thought because that repo lives in the examples section and had been updated recently that Puppeteer might now work better on Netlify, but I’ve still to find a working example (at least on a free account).

Thanks for the info! I did try updating the package.json and found the 10 second issue! So close…

I appreciate the message because I might have poured a lot of time into this!

I already have :expressionless:

Would love to get it working.

There is a possibility of increasing function run time to around 20s if you upgrade your site’s function to level 1. Once you upgrade contact us and we can make the change for you.