easy-livereload icon indicating copy to clipboard operation
easy-livereload copied to clipboard

EMFILE error when using fs.watch on many items

Open NetanelBasal opened this issue 10 years ago • 8 comments

I am using your module and i am getting error because i have too many files to watch.

app.use(require('easy-livereload')({ watchDirs: [ path.join(__dirname, 'public') ], checkFunc: function(file) { return /.(css|js|jade)$/.test(file); }, port: process.env.LIVERELOAD_PORT || 35729 }));

NetanelBasal avatar Feb 24 '15 07:02 NetanelBasal

Please try increasing the file descriptor limit.

What is the result of the following?

ulimit -n

dai-shi avatar Feb 24 '15 08:02 dai-shi

4864

NetanelBasal avatar Feb 24 '15 09:02 NetanelBasal

Do you have more files than that number?

How about try something like this?

ulimit -n 65536

dai-shi avatar Feb 24 '15 09:02 dai-shi

I does not have so many file and i am still get this error

throw errnoException(err, 'watch');
      ^

Error: watch ENFILE at exports._errnoException (util.js:732:11) at FSWatcher.start (fs.js:1155:11) at Object.fs.watch (fs.js:1181:11) at watch (/Users/netanelbasal/www/node/node_modules/easy-livereload/node_modules/node-watch/lib/watch.js:221:8) at /Users/netanelbasal/www/node/node_modules/easy-livereload/node_modules/node-watch/lib/watch.js:230:9 at /Users/netanelbasal/www/node/node_modules/easy-livereload/node_modules/node-watch/lib/watch.js:41:14 at Array.forEach (native) at /Users/netanelbasal/www/node/node_modules/easy-livereload/node_modules/node-watch/lib/watch.js:38:18 at FSReqWrap.oncomplete (fs.js:76:15) 24 Feb 11:15:04 - [nodemon] app crashed - waiting for file changes before starting...

NetanelBasal avatar Feb 24 '15 09:02 NetanelBasal

Hmm, it sounds tough.

dai-shi avatar Feb 24 '15 09:02 dai-shi

Is this related? https://github.com/joyent/node/issues/2479

dai-shi avatar Feb 24 '15 23:02 dai-shi

Thats wired, my ulimit is 65536, i dont think this is related to this. I am sure more users will be come to this problem so if i find solution i will write this here.

NetanelBasal avatar Feb 25 '15 06:02 NetanelBasal

https://stackoverflow.com/a/32600959/353166 worked for me

jonmann20 avatar Jul 03 '19 19:07 jonmann20