Error on successfully Deployed Lambda Endpoint

Hi,
I am trying out Netlify Functions for the first time.
I have a function which has a dependency on node canvas.
I have successfully deployed my function but whenever I hit the endpoint it throws an error which I think is due to some missing libraries from the netlify system.
Below is the Error:

{
errorType: "Error",
errorMessage: "libuuid.so.1: cannot open shared object file: No such file or directory",
trace: [
"Error: libuuid.so.1: cannot open shared object file: No such file or directory",
" at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at Module.require (internal/modules/cjs/loader.js:887:19)",
" at require (internal/modules/cjs/helpers.js:74:18)",
" at Object.<anonymous> (/var/task/node_modules/canvas/lib/bindings.js:3:18)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)"
]
}

Hi @ARogueOtaku,

Is there a code or repo that we can test?

Hi @hrishikesh,

Yes. I am trying to Implement a Telegram Bot using Telegraf. It uses chartjs-node-canvas, chartjs-plugin-datalabels, convert-csv-to-json and node-fetch as the main dependencies. I intend to use the netlify fucntion as a webhook for the bot.
Here is the link to the Public Repo: Telegram Cov Bot

I think you can try moving the utils folder inside the endpoints folder and require the files from the new path. This is how I do it: https://github.com/Hrishikesh-K/OpinionJS/blob/main/src/functions/addComment.js#L6-L10

Thanks,

I will try that out tonight, and let you know what happens.
Just 1 question as I am very new to netlify. I thought that the functions folder specified in the netlify.toml file is the folder dedicated to only the lambda functions. So if I move the /utils inside the /endpoins, won’t that mean that all of the files inside /util will also be treated as a netlify function? And as a result the build will fail?

Only the files directly inside the functions folder are treated as serverless functions. Any file inside a folder in the functions folder is not treated as a function. So you can use it to store your custom modules.

So in your case:

endpoint/foo.js will be a function.
endpoint/utils/bar.js won’t be a function.

Hi @hrishikesh,

I tried moving the Utils inside my Functions folder but that did not seem to solve the issue.


Any Idea what may be causing this issue?
Thanks again for helping me with this!

Hi @ARogueOtaku,

The problem is that the AWS runtime doesn’t have the prebuilt dependency anymore. What you can do is, find which of your dependencies needs that liquid.so and see if they’ve have a solution to skip it, or use an alternative library.

If that’s not an option, you might have to get hacky like this: