[Apple M1] Don't compile on IOS metro-hermes-compiler too many open files
Bug Description
- Hermes version: 0.7.2
- React Native version: 0.64.0
- OS version: macOS 11.2.3
- Platform: arm64 (Apple M1)
Steps To Reproduce
- Update existing project from 0.63.4 to 0.64.0
- Compile with Xcode
The Expected Behavior
Pre-version compiles fine
Error Message
Showing All Messages
+ PACKAGER_SOURCEMAP_FILE=
+ [[ '' == true ]]
+ /Users/alexander/Code/Sputnik/sputnik-app/node_modules/@sentry/cli/sentry-cli /Users/alexander/Code/Sputnik/sputnik-app/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/alexander/Library/Developer/Xcode/DerivedData/SputnikApp-fjypaeaptflxsubdwkhkfnnxdzqv/Build/Products/Release-iphonesimulator/main.jsbundle --assets-dest $'/Users/alexander/Library/Developer/Xcode/DerivedData/SputnikApp-fjypaeaptflxsubdwkhkfnnxdzqv/Build/Products/Release-iphonesimulator/\320\241\320\277\321\203\321\202\320\275\320\270\320\272.app' --sourcemap-output /Users/alexander/Library/Developer/Xcode/DerivedData/SputnikApp-fjypaeaptflxsubdwkhkfnnxdzqv/Build/Intermediates.noindex/SputnikApp.build/Release-iphonesimulator/SputnikApp.build/DerivedSources/main.jsbundle.map
Welcome to Metro!
Fast - Scalable - Integrated
/Users/alexander/Code/Sputnik/sputnik-app/node_modules/metro-hermes-compiler/src/emhermesc.js:81
throw ex;
^
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 NodeWatcher.checkedEmitError (/Users/alexander/Code/Sputnik/sputnik-app/node_modules/sane/src/node_watcher.js:143:12)
at FSWatcher.emit (node:events:369:20)
at FSEvent.FSWatcher._handle.onchange (node:internal/fs/watchers:210:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
the transform cache was reset.
Command PhaseScriptExecution failed with a nonzero exit code
Additional Info
Newly created React Native project is being compiled successfully. The issue only with a existing project.
+1 i also get this error on M1
warning: the transform cache was reset.
Welcome to Metro!
Fast - Scalable - Integrated
/Users/gedeagas/Work/Kumparan/kumparan-mobile-app/node_modules/metro-hermes-compiler/src/emhermesc.js:81
throw ex;
^
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 NodeWatcher.checkedEmitError (/Users/gedeagas/Work/Kumparan/kumparan-mobile-app/node_modules/sane/src/node_watcher.js:143:12)
at FSWatcher.emit (node:events:378:20)
at FSEvent.FSWatcher._handle.onchange (node:internal/fs/watchers:210:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
Same problem
try deleting the yarn.lock file and peforming yarn install
fsevents is the module that causes it to break. Upgrade fsevents to fix it:
// yarn.lock
fsevents@^2.1.2:
- version "2.1.3"
- resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e"
- integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==
+ version "2.3.2"
+ resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
+ integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
@JonnyBurger @owinter86 fsevents upgrade to 2.1.3 works like a charm, many thanks.
only doing this does not always help
fseventsis the module that causes it to break. Upgrade fsevents to fix it:// yarn.lock fsevents@^2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" - integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
you save me, tks bro!
fseventsis the module that causes it to break. Upgrade fsevents to fix it:// yarn.lock fsevents@^2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" - integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
not working, after reinstall 'watchman', upgrade fsevent.
it can be debug on simulator, but not archive.
any solution?
upgrading fsevent didn't helped me either
my output is
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 NodeWatcher.checkedEmitError (/Users/juxhin/Projects/openbar_frontend/node_modules/sane/src/node_watcher.js:143: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
}```
Welcome to React Native!
Learn once, write anywhere
node:events:491
throw er; // Unhandled 'error' event
^
Error: EMFILE: too many open files, watch
at FSWatcher._handle.onchange (node:internal/fs/watchers:204:21)
Emitted 'error' event on NodeWatcher instance at:
at NodeWatcher.checkedEmitError (/Users/*/Desktop/*/*/node_modules/sane/src/node_watcher.js:143:12)
at FSWatcher.emit (node:events:513:28)
at FSWatcher._handle.onchange (node:internal/fs/watchers:210:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
Node.js v18.12.1
main.jsbundle does not exist. This must be a bug with
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
Same here, on M1 Pro, Ventura 13, XCode 14.1 already: upgraded watchman, fsevent.
There are a couple of issues conflated here I think.
- The previous minimum version of
fseventshad no M1 build available, so some existing projects may have included a version offseventsincompatible with their machine, causing Metro to fall back from macOS-native to a less optimised Node JS watcher. Clearing/updating your lockfile (as suggested above) would've fixed this, and we bumped the minimum for future RN versions:
- https://github.com/facebook/metro/pull/875 (Metro 0.73 / RN 0.71)
- "Too many open files" is not an M1-specific issue. That's coming up against the configured limits of macOS, whose FSEvents API is used under the hood by
fsevents, Watchman, and Node itself. Perhaps try one/both of the approaches below and please do let us know what works for you:
Use a combined kqueue+fsevents watcher
Newer versions of Watchman allow the use of a combined FSEvents + kqueue watch strategy to reduce the load on FSEvents (similar to newer versions of Node's fs.watch). You can try that mode by installing the latest version of Watchman from Homebrew and adding this line to your .watchmanconfig (create it in your project root if it doesn't exist already):
{
"watcher": "kqueue+fsevents"
}
Verify that you're using this watcher backend with watchman watch-project /absolute/path/to/your/project/root on the command line. You should see watcher: "kqueue+fsevents" in the output. Ensure you don't have useWatchman: false in your Metro config, and hopefully this will help.
Raise system limits on open file descriptors
Ensure you are using Watchman, and follow instructions below to raise the watch limits on your machine:
Put the following into a file named /etc/sysctl.conf on macOS to cause these values to persist across reboots:
kern.maxfiles=10485760 kern.maxfilesperproc=1048576
Source: https://facebook.github.io/watchman/docs/install.html#macos-file-descriptor-limits
Welcome to React Native! Learn once, write anywhere node:events:491 throw er; // Unhandled 'error' event ^ Error: EMFILE: too many open files, watch at FSWatcher._handle.onchange (node:internal/fs/watchers:204:21) Emitted 'error' event on NodeWatcher instance at: at NodeWatcher.checkedEmitError (/Users/danieltirrier/Desktop/APPSPANEL/azap-react/node_modules/sane/src/node_watcher.js:143:12) at FSWatcher.emit (node:events:513:28) at FSWatcher._handle.onchange (node:internal/fs/watchers:210:12) { errno: -24, syscall: 'watch', code: 'EMFILE', filename: null } Node.js v18.12.1 main.jsbundle does not exist. This must be a bug with + echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'Same here, on M1 Pro, Ventura 13, XCode 14.1 already: upgraded watchman, fsevent.
/node_modules/react-native/scripts/react-native-xcode.sh add export PATH=/opt/homebrew/bin:$PATH work for me
fseventsis the module that causes it to break. Upgrade fsevents to fix it:// yarn.lock fsevents@^2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" - integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==not working, after reinstall 'watchman', upgrade fsevent.
it can be debug on simulator, but not archive.
any solution?
@skanger did you find any solution?
Tried everything and realized there was no fsevents in my node_modules (even though it's a newly properly created react native project), did 'npm install fsevents' and this solved the issue.
Thanks, it works for me on rn v.0.74 and node 18.14.2
Running into this again on node 20, any new fix in 2024?
Thanks, it works for me on rn v.0.75.3 and node 20.17.0.
npm install fsevents fixed mine, RN team, this problem still exist now Dec 2024.
What worked for me, I changed my node version to 18.17.0 then I deleted the node_modules folder then re-install using npm i