Include binaries in function, netlify-lambda


Hello all,

I’ve been struggling with this issue for a day or two now.

I’m using a regular Gatsby + Netlify setup, I’m using netlify-lamda package to enable functions in development and production builds. Everything works as expected.

Issue is, I created a new function that is using a package called node-canvas. From what I understand, the package has a pre-built binary called canvas.node which is required in order to work.

I was wondering how can I include a binary using the netlify-lambda package or using webpack? (using the -c flag)

If anyone is willing to help, I will appreciate it a lot. If you need more information, I will be happy to update this message or setup a demo application to reproduce.



Hey @kinduff

When including binaries in functions they can’t be processed/transpiled via webpack without special setup described here

I’d recommend dropping webpack/netlify lambda and simply using the zip based deployments.

Here is an example of using a binary (in this case headless chrome) and a zip based function

When including a binary in a lambda, it needs to be a binary compiled for the lambda linux distro. Hopefully there is already an npm package that includes your precompiled binary to run in lambda like the linked example.

If there is not, this article will walk through compiling the binary in a docker container for use in a function

PS what kind of binary are you trying to run?

1 Like

Thank you very much for the guidance. I ended up creating my own bash script to install and zip each of the functions I have. I really wanted to use netlify-lambda, but hope I can contribute to add this functionality in the future.


@DavidWells I tried your example (with chrome) but when I run the function it times out. I get the error message:

11:17:17 PM: chrome invoked
11:17:18 PM: spawning chrome headless
11:17:28 PM: Task timed out after 10.01 seconds

Is there anything I can configure to change this?


Nothing you can configure, but we can update the timeout for you on that site, once you upgrade to Functions Level 1 (see The free tier has a 10 second timeout on functions, but we can up it to 28 seconds max for any upgraded sites. If you do this, please ping us in the helpdesk with the site name, and a link to this thread and we’ll be happy to get you set up.