Error: EMFILE: too many open files, watch
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
Bug Report
I upgraded the app to the new arch (0.76.x) and now I am getting this error when trying to archive in xcode:
node:events:491
throw er; // Unhandled 'error' event
^
Error: EMFILE: too many open files, watch
at FSEvent.FSWatcher._handle.onchange (node:internal/fs/watchers:204:21)
Emitted 'error' event on NodeWatcher instance at:
at FSWatcher._checkedEmitError (node_modules/metro-file-map/src/watchers/NodeWatcher.js:82:12)
at FSWatcher.emit (node:events:513:28)
at FSEvent.FSWatcher._handle.onchange (node:internal/fs/watchers:210:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
What is the current behavior?
App works fine, in dev as well as in release mode on both android as well as in iOS. First i was getting this error in terminal too when running npm start but that was fixed by deleting node_modules and reinstalling deps but archiving is still throwing this error.
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
Set Run scheme to Release and change run destination to Any iOS device, and try to archive.
What is the expected behavior?
Archive should be executed successfully instead of throwing a metro bundler error.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
metro - v0.81.0
node - v22.11.0
npm - v10.9.0
react-native - 0.76
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure by setting the Xcode scheme to Release and archiving for Any iOS device, then inspect node_modules/metro-file-map/src/watchers/NodeWatcher.js around line 82 and the Node watcher error path. Compare the archive behavior with npm start, using the reported Metro 0.81.0, Node 22.11.0, and React Native 0.76 versions. Done means the archive completes without the EMFILE watch error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, react-native
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100