I work with a couple different nodejs live servers as part of my job and there seems to be some kind of leak within my tooling/workflow causing file watchers to accumulate over time until they hit the system limit. I then get the following cli errors:
Error from chokidar (<path-to-folder>): Error:
ENOSPC: System limit for number of file watchers reached, watch '<path-to-folder>/<filename>'
I found the following command that should return the number of wile watchers of use:
find /proc/*/fd -user "$USER" -lname anon_inode:inotify -printf '%hinfo/%f\n' 2>/dev/null | xargs cat | grep -c '^inotify'
and it returns 515160, even though I've seemingly shut down all of my live servers. I have two sets of questions:
- How can I diagnose this? Can I get a list of all registered watchers, their watched path and corresponding PID, or something of that sort?
- Is there a way for me to kill them all? Is killing all file watchers even a good idea? Can I kill only watchers registered by my servers?
I'm running debian 11
cat |
part from the command.