Memory Usage & Puppeteer - function, or repo-based?

Hi all,

first time posting (so apologies if I get something wrong). I’m trying to get https://bitsofco.de/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 :slight_smile:

Also would be useful to know if you can run locally using netlify-lambda serve or netlify dev ?

Hi @fool. Thanks a lot for replying.

Repo is here: https://github.com/coderkind/gatsby-lambda-screenshot-demo
Function is here: https://xenodochial-newton-c1604d.netlify.com/.netlify/functions/screenshot

I haven’t gotten the lambda to work locally yet.

The function log for the above says:
7:23:23 PM: 2019-12-03T19:23:23.721Z 102894ba-3022-438c-98c7-0ef066d4fd5f {“errorMessage”:“Failed to load ‘iltorb’ package.”,“errorType”:“Error”,“stackTrace”:[“Function.get brotli [as brotli] (/var/task/screenshot.js:8:48749)”,“Promise (/var/task/screenshot.js:8:49698)”,“new Promise ()”,“inflate (/var/task/screenshot.js:8:49327)”,“Function.get executablePath [as executablePath] (/var/task/screenshot.js:8:47812)”,“t.handler (/var/task/screenshot.js:1:345908)”]}
7:23:23 PM: Duration: 9.39 ms Memory Usage: 69 MB Init Duration: 126.32 ms
7:28:00 PM: 2019-12-03T19:28:00.030Z f264db1c-f84a-4229-8f08-a4ea2b649bbb {“errorMessage”:“spawn ETXTBSY”,“errorType”:“Error”,“stackTrace”:["_errnoException (util.js:1022:11)",“ChildProcess.spawn (internal/child_process.js:323:11)”,“Object.exports.spawn (child_process.js:502:9)”,“e.exports.launch (/var/task/screenshot.js:8:12789)”,""]}
7:28:00 PM: Duration: 32.61 ms Memory Usage: 69 MB

error seems pretty straightforward:

“Failed to load ‘iltorb’ package.”

You are clearly not including it in your function, nor in your package.json in that repo.

so…try including it?

Unfortunately not (but just added it again); I’ve played around with including this in the past. I’ve added and deployed things with it in once more, but a different error now from https://xenodochial-newton-c1604d.netlify.com/.netlify/functions/screenshot - “spawn ETXTBSY”