fix: prevent EMFILE error in environment with low file descriptors limit#306
fix: prevent EMFILE error in environment with low file descriptors limit#306
Conversation
66c04b8 to
79a53c0
Compare
|
We usually take adding new libraries to npm pretty slowly, especially something as low-level as I think what's needed here is a more holistic assessment of |
One option I considered was to make this a feature rather than a bug fix and add a parameter for a Another option might be to just write the backoff behaviour into this library directly. But that's arguably more risky than using a well-established library. Interesting that you already monkey patch |
npm installcan fail with aEMFILEerror in certain environments. From the docs on common system errors:I've seen it building a Node.js v20 container image on a Kubernetes cluster using
buildah, as described here. In my case it's a CI environment where I can't easily do the suggested fix of increasing the file descriptor limit with a flag on the build command, and that seems like a workaround anyway. I've also seen it when building a Node.js v18 container image usingpodmanin GitHub Actions. I'm guessing it's more common in CI environments.This PR fixes the issue by replacing
node:fswithfs-extra.fs-extrausesgraceful-fsunder the hood, which does an incremental backoff if anEMFILEerror is encountered.Both
fs-extraandgraceful-fsare intended to be a drop-in replacement fornode:fs.graceful-fsseems like a better choice because it's targeted to solving this specific problem, but it doesn't yet support thefsPromises API (isaacs/node-graceful-fs#160) whereasfs-extradoes.References
Fixes #261