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.
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.
- run: ulimit -n 65536
- run: npm run buildReduce concurrent file access
Lower test/build parallelism and narrow watchers so fewer descriptors are open at once.
- Cap test workers (for example jest --maxWorkers=50%).
- Restrict watch globs to the directories you actually need.
- Use graceful-fs-style FD queuing where the tool supports it.
How to prevent it
- Set a generous
ulimit -nin CI for file-heavy builds. - Bound parallelism in test and build steps.
- Avoid watching enormous trees in CI.