metro: [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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 27
- Comments: 15 (1 by maintainers)
fseventsis the module that causes it to break. Upgrade fsevents to fix it:try deleting the yarn.lock file and peforming
yarn installTried 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.
There are a couple of issues conflated here I think.
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: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):Verify that you’re using this watcher backend with
watchman watch-project /absolute/path/to/your/project/rooton the command line. You should seewatcher: "kqueue+fsevents"in the output. Ensure you don’t haveuseWatchman: falsein 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:
Source: https://facebook.github.io/watchman/docs/install.html#macos-file-descriptor-limits
Same here, on M1 Pro, Ventura 13, XCode 14.1 already: upgraded watchman, fsevent.
upgrading
fseventdidn’t helped me eithermy output is
node version v12, v14, v16, v18 all failed. output:
Failed to construct transformer: TypeError: fsevents is not a function at new FSEventsWatcher (/Users/boywus/easyspark/f/node_modules/metro/node_modules/jest-haste-map/build/lib/FSEventsWatcher.js:162:20) at createWatcher (/Users/boywus/easyspark/f/node_modules/metro/node_modules/jest-haste-map/build/index.js:1052:23) at Array.map (<anonymous>) at HasteMap._watch (/Users/boywus/easyspark/f/node_modules/metro/node_modules/jest-haste-map/build/index.js:1230:44) at /Users/boywus/easyspark/f/node_modules/metro/node_modules/jest-haste-map/build/index.js:517:21 at Generator.next (<anonymous>) at asyncGeneratorStep (/Users/boywus/easyspark/f/node_modules/metro/node_modules/jest-haste-map/build/index.js:193:24) at _next (/Users/boywus/easyspark/f/node_modules/metro/node_modules/jest-haste-map/build/index.js:213:9) at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:95:5)not working, after reinstall ‘watchman’, upgrade fsevent.
it can be debug on simulator, but not archive.
any solution?