Netlify functions child_process.execFile temporary EACCES error

Hi!
I recently updated my application (https://axilla.netlify.app/) to Ubuntu Focal 20.04 (was previously on a now-deprecated image). The app is essentially a single Netlify (lambda) function that calls child_process.execFile() on an executable included in my function directory.

It had been over a year since I updated the executable and this was the first time deploying with the new build image. After deploying, calling child_process.execFile() in the function results in an EACCES permission error. However, after 10-20 minutes, the error goes away and everything works fine.

Any ideas what is happening here? Thanks in advance!

Hard to say. Mind sharing a reproduction we can check?

Repo is public: GitHub - btjones/axilla: A web-based implementation of Pixlet.

If you fork and open a PR, the deploy preview should reproduce the issue. I can do it myself too but it will resolve itself in 10 minutes or so. The issue can be seen by visiting the deploy preview root - the function is automatically run from the root.

This is weird indeed. I have asked the devs to take a look.

1 Like

As an update, the devs have reached out to AWS Support to see what could be happening here.

1 Like

This is what AWS Support has to say:

TL;DR: Try copying your binary to /tmp before executing.

Greetings,

We appreciate you reaching out to AWS Premium Support. My name is [redacted] and I will be assisting you with your case.

From my review of the case information, I understand that your customers report experiencing an intermittent issue with the Lambda function: [redacted] returning the following runtime error: spawn functions/axilla/pixlet-aws EACCESS during execution.

To begin my investigation, I evaluated the information provided with the initial correspondence and the function code via the GitHub link. From my review of the function code, it does appear that the function builds a path for an executable file during the execution:

const execFile = util.promisify(require(‘child_process’).execFile)

const executePixlet = async (args) => {
const command = PIXLET_BINARY_PATH ? path.join(PIXLET_BINARY_PATH, PIXLET_BINARY) : PIXLET_BINARY
const opts = LD_LIBRARY_PATH ? { env: { LD_LIBRARY_PATH } } : undefined
return execFile(command, args, opts)
}

Typically, when function reports an EACCESS error than it would relate to Lambda experiencing a permission issue when trying to access the specific directory or executable file. Alternatively, it could also be returned if Lambda is unable to locate the executable file during the execution as well [1] [2].

If it is the former than the executable file would require 755 permissions applied for Lambda to access the file during execution. However, as the issue is reported to occur intermittently then I believe it would most likely be the latter; which, it could be beneficial to copy the executable file into the /tmp directory (ephemeral storage) of the function [3].

It is important to note that code developer/debugging does fall outside the scope of support for us at AWS Premium Support [4]. With that being said, my analysis of the issue was provided on a best effort basis as my knowledge of the scripting language: Java Script is not too in depth. However, I will continue to offer any additional support to the best of my ability.

As always, if you have any additional questions, concerns, or need any clarification, please do not hesitate to reach out. I’d be more than happy to address them for you.

References:

[1] Troubleshoot deployment issues in Lambda - AWS Lambda
[2] Running Arbitrary Executables in AWS Lambda | AWS Compute Blog
[3] Using larger ephemeral storage for AWS Lambda | AWS Compute Blog
[4] AWS Premium Support FAQs | AWS Support