Lambda function failing in @netlify/build 20.3.1

I am generating PDFs through Chrome’s Puppeteer. In a deployment using Netlify’s build tool 19.0.7, generating PDFs works:

12:43:36 PM: ────────────────────────────────────────────────────────────────
12:43:36 PM:   Netlify Build                                                 
12:43:36 PM: ────────────────────────────────────────────────────────────────
12:43:36 PM: ​
12:43:36 PM: ❯ Version
12:43:36 PM:   @netlify/build 19.0.7
12:43:36 PM: ​
12:43:36 PM: ❯ Flags
12:43:36 PM:   baseRelDir: true
12:43:36 PM:   buildId: 61a53b5613ce830007b51c44
12:43:36 PM:   deployId: 61a53b5613ce830007b51c46
12:43:36 PM: ​
12:43:36 PM: ❯ Current directory
12:43:36 PM:   /opt/build/repo
12:43:36 PM: ​
12:43:36 PM: ❯ Config file
12:43:36 PM:   /opt/build/repo/netlify.toml
12:43:36 PM: ​
12:43:36 PM: ❯ Context
12:43:36 PM:   branch-deploy

But on newer deploys using 20.3.1, PDF generation causes a 500 error because a library cannot be found:

11:03:54 AM: ────────────────────────────────────────────────────────────────
11:03:54 AM:   Netlify Build                                                 
11:03:54 AM: ────────────────────────────────────────────────────────────────
11:03:54 AM: ​
11:03:54 AM: ❯ Version
11:03:54 AM:   @netlify/build 20.3.1
11:03:54 AM: ​
11:03:54 AM: ❯ Flags
11:03:54 AM:   baseRelDir: true
11:03:54 AM:   buildId: 61b8ea64dca45400073fea15
11:03:54 AM:   deployId: 61b8ea64dca45400073fea17
11:03:54 AM: ​
11:03:54 AM: ❯ Current directory
11:03:54 AM:   /opt/build/repo
11:03:54 AM: ​
11:03:54 AM: ❯ Config file
11:03:54 AM:   /opt/build/repo/netlify.toml
11:03:54 AM: ​
11:03:54 AM: ❯ Context
11:03:54 AM:   branch-deploy

When trying to generate the PDF, my function logs show:

2:24:09 PM: 999fae5f INFO   Generating PDF...
2:24:12 PM: 999fae5f INFO   error Error: Failed to launch the browser process!
/tmp/chromium: error while loading shared libraries: cannot open shared object file: No such file or directory

My code isn’t different, so I’m not sure how to proceed.

Hi @zackseuberling

Build and functions are different, especially when functions run. I suggest this breakage is not due to the build image itself, but the changing of the default node version used in lambda functions which came into effect a few days ago.

dang, I was really hoping it was something as easy at this. maybe it still is and I’m doing something wrong, but adding this to my netlify.toml file, and I am still running into the same issues:

  AWS_LAMBDA_JS_RUNTIME = "nodejs12.x"

Maybe someone could explain this, BUT — I did add the environment variable in the Netlify UI, and it seems to be working at this point.

Why/when do Netlify UI environment variables take precedence over the netlify.toml environment variables? Or maybe I didn’t apply them correclty in my netlify.toml file?

Honestly have not used Puppeteer. This post seems relevant though

1 Like

wow! the note in one of the answers about needing versions >= 6.0.0 for nodejs14.x seems like the most relevant piece. I will probably give that a shot and see if it also works, so I’m not stuck on nodejs12.x forever.

1 Like

The answer is, they always take preference as variable defined in netlify.toml are limited to build time only, but functions need runtime variables.

I’m not sure I understand this. According to the Netlify documentation here, I should be able to configure the AWS_LAMBDA_JS_RUNTIME in my netlify.toml file since it’s not listed in the section explicitly telling me to configure it in the Netlify UI.

I did attempt to configure it in my netlify.toml file, and readily admit that I may have configured it incorrectly.

If you create/set an environment variable in the Netlify UI, and create/set the same variable in the netlify.toml in a repository, the build system will take the value from the netlify.toml, not the value from the UI.

The value (as you have previously shown) is in line with the Netlify documentation and the AWS documentation.