EAS Android Build Failure - ENOSPC: System limit for number of file watchers reached

Workflow: Managed
EAS CLI version: eas-cli/2.1.0 darwin-x64 node-v14.19.0

I have been getting the following error since 2022-09-26T04:18:49Z.
The same android app was successfully built before this time.

Task :app:bundleReleaseJsAndAssets FAILED
[stderr] /home/expo/workingdir/build/node_modules/metro-hermes-compiler/src/emhermesc.js:77
[stderr] throw ex;
[stderr] ^
[stderr] Error: ENOSPC: System limit for number of file watchers reached, watch ‘/home/expo/workingdir/build/node_modules/expo-dev-launcher/android/build/intermediates/library_assets’
[stderr] at FSWatcher. (internal/fs/watchers.js:243:19)
[stderr] at Object.watch (fs.js:1586:34)
[stderr] at NodeWatcher.watchdir (/home/expo/workingdir/build/node_modules/jest-haste-map/build/watchers/NodeWatcher.js:156:24)
[stderr] at Walker. (/home/expo/workingdir/build/node_modules/jest-haste-map/build/watchers/common.js:113:31)
[stderr] at Walker.emit (events.js:400:28)
[stderr] at /home/expo/workingdir/build/node_modules/walker/lib/walker.js:69:16
[stderr] at FSReqCallback.oncomplete (fs.js:179:23) {
[stderr] errno: -28,
[stderr] syscall: ‘watch’,
[stderr] code: ‘ENOSPC’,
[stderr] path: ‘/home/expo/workingdir/build/node_modules/expo-dev-launcher/android/build/intermediates/library_assets’,
[stderr] filename: ‘/home/expo/workingdir/build/node_modules/expo-dev-launcher/android/build/intermediates/library_assets’
[stderr] }

I am aware that this is an issue with inotify limit and need to increase the limit (fs.inotify.max_user_watches).
What I don’t understand is why this has started happening and wondering if there is anything I can do to avoid this issue?

Thank you.

can you share a link to your project? you should be able to bump that limit if you want to (in a build lifecycle hook), or install watchman. but we can look into this more for you if you can share a link

Thank you for your response. Here’s the link to a failed build.

I have completely forgot about the build lifecycle hooks. I will look into this.
Thank you for directing me to this.

I’ve added the following build lifecycle hook and the issue has been fixed.

"eas-build-pre-install": "sudo sysctl -w fs.inotify.max_user_watches=524288",
1 Like