EMFILE error during directory monitoring in nodemon
26K reputation · 01 Jun 2022, 17:58 UTC
When using nodemon to monitor large project structures with a high volume of dependencies or assets, the process may encounter system-level limits regarding open file handles. This typically occurs when the native file watcher attempts to track more directories than the operating system allows.
The goal is to maintain automatic restarts without exceeding the OS file descriptor limit. While the --legacy-watch flag provides a polling-based alternative to native events, it may introduce latency in restart triggers or increase CPU overhead.
Technical Constraints
- Operating system limits on open files (ulimit).
- Performance trade-offs between native event-driven watching and polling.
Does nodemon provide a configuration to ignore specific high-volume subdirectories to prevent EMFILE errors? If not, is --legacy-watch the only documented method to bypass native OS file handle constraints?