first time posting (so apologies if I get something wrong). I’m trying to get How to use Puppeteer in a Netlify (AWS Lambda) function working, but I think I’m exceeding the lambda-functions memory limit. I’m elaborating on this Puppeteer demo by trying to get it working within a basic Gatsby site, but my “screenshot” function states “Memory Usage: 85 MB” when I try and hit the endpoint, and it fails with “ENOENT: no such file or directory, open ‘//…/bin/chromium.br’”.
However, a separate, basic “Hello, world!” function within the same repo (which works) is saying “Memory Usage: 77 MB” (which seems massive for what it’s doing).
Even this would exceed the supposed 50MB memory allocation, right? So why does it still work?
Is the memory usage of each function based on that individual function, or whatever else is being installed as part of the package.json?
I don’t think there is a 50Mbyte allocation limit; we pin you at 1Gb mem usage in lambdas.
The limitations folks usually run into are usually on function size on disk (50/250 zipped/not), not memory used.
That error message also doesn’t sound like an “out of memory” but rather a missing file.
If you have a successful deploy and URL for the function and could share the link to the logs and the URL for the function for us to look at, that’d be a good start for us to try to see what is happening
Also would be useful to know if you can run locally using netlify-lambda serve or netlify dev ?
1:09:22 AM: 2019-12-10T01:09:22.111Z 0e3372d5-7033-4f3b-8f4b-7cb68e2bcc41 INFO spawning chrome headless
1:09:24 AM: 2019-12-10T01:09:24.614Z 0e3372d5-7033-4f3b-8f4b-7cb68e2bcc41 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
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:215:7)
at Interface.close (readline.js:403:8)
at Socket.onend (readline.js:180:10)
at Socket.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
1:09:24 AM: Duration: 2517.40 ms Memory Usage: 398 MB Init Duration: 278.64 ms
1:09:41 AM: 2019-12-10T01:09:41.314Z f3436fb2-1430-471a-a53c-a25d75723c9b INFO spawning chrome headless
1:09:41 AM: 2019-12-10T01:09:41.349Z f3436fb2-1430-471a-a53c-a25d75723c9b 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
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:215:7)
at Interface.close (readline.js:403:8)
at Socket.onend (readline.js:180:10)
at Socket.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
1:09:41 AM: Duration: 37.48 ms Memory Usage: 398 MB
1:09:50 AM: 2019-12-10T01:09:50.096Z b668f5af-9f5c-4508-8517-752a2ecee409 INFO spawning chrome headless
1:09:50 AM: 2019-12-10T01:09:50.108Z b668f5af-9f5c-4508-8517-752a2ecee409 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
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:215:7)
at Interface.close (readline.js:403:8)
at Socket.onend (readline.js:180:10)
at Socket.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
1:09:50 AM: Duration: 18.38 ms Memory Usage: 398 MB
Can’t really say what’s going on there specifically:
/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
…other than that is a shared library that did not seem to get packaged up with your function. You’re saying that the one that Gerald asked you to deploy doesn’t work for you? What happened when you tried? I don’t think the same error would have shown up there since that setup should work for everyone without the error you show.
Also in general - you’ll need to get a function working locally before it can work here, so that is always step 0 before trying to deploy.
Can you see how much memory your function is consuming when you get it running locally? I’m curious if it needs 1.5gb since we provide 1gb in functions.
You could probably do something like run top on your unix-based development machine to watch how much memory the process is using in realtime. Or, some of the options in this thread may work: command line - Peak memory usage of a linux/unix process - Stack Overflow . I don’t know an equivalent on windows. I don’t think netlify dev will provide you much detail on memory usage natively.
Hi @silentfail , I realize that you had this issue a century ago, but have you ever solved it and do you have such an amazing memory that you recall how? Thanks
It looks like you haven’t gotten much traction on this since you reached out last week. Apologies for that! Are you still encountering obstacles? If so, can you please share your site, the obstacle you are encountering, and what you have tried so far?
I’m having some issues with a function that uses Puppeteer, sometimes timing out because of how long the function takes to visit a website and transform it into a pdf. I think I know wy, but I’ll come back to you if I need further assistance.