Skip to content
Latchkey

Node.js "EMFILE: too many open files" in CI

A process exceeded the per-process file-descriptor limit. Tools that open many files at once (bundlers, test runners, watchers) hit EMFILE on runners with a low ulimit.

What this error means

A build or test run fails with EMFILE: too many open files. It can be intermittent depending on concurrency, and often points at a glob or a parallel file-reading step.

node
Error: EMFILE: too many open files, open
'/work/repo/src/components/Button.tsx'
  errno: -24,
  code: 'EMFILE',
  syscall: 'open'

Common causes

The file-descriptor ulimit is too low

A runner with a small ulimit -n is exhausted by tools that open many files concurrently.

Too much parallel file access

A wide glob, a watcher over a huge tree, or high test concurrency opens more descriptors than allowed at once.

How to fix it

Raise the open-file limit

Increase the ulimit in the job before the build runs.

workflow
- run: ulimit -n 65536
- run: npm run build

Reduce concurrent file access

Lower test/build parallelism and narrow watchers so fewer descriptors are open at once.

  1. Cap test workers (for example jest --maxWorkers=50%).
  2. Restrict watch globs to the directories you actually need.
  3. Use graceful-fs-style FD queuing where the tool supports it.

How to prevent it

  • Set a generous ulimit -n in CI for file-heavy builds.
  • Bound parallelism in test and build steps.
  • Avoid watching enormous trees in CI.

Frequently asked questions

What causes ""EMFILE: too many open files""?
A runner with a small ulimit -n is exhausted by tools that open many files concurrently.
How do I fix "EMFILE: too many open files"?
Increase the ulimit in the job before the build runs.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card