fs.watch() on Linux

971 views
Skip to first unread message

Frederik Berg

unread,
Jul 30, 2012, 4:14:45 PM7/30/12
to nod...@googlegroups.com
Hi,
this worked fine 1 or 2 days ago but now all of a sudden it dosn't

var fs = require('fs');
fs.watch('serve/'+'favicon.ico', function (event, filename) {if(event==='change' && filename) console.log(filename);});

keeps throwing:
fs.js:837
    throw errnoException(errno, 'watch');
          ^
Error: watch ENOSPC
    at errnoException (fs.js:806:11)
    at FSWatcher.start (fs.js:837:11)
    at Object.fs.watch (fs.js:861:11)
    at Object.<anonymous> (/win-c/Users/Frederik/Downloads/!terminal/server.js:6:4)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

I didn't update node since last time (it's 0.8.4)
and I'm definitely sure it worked last time I executed the script
the last change (after which it still worked) was moving the watched files to the subfolder serve/ but changing that back dosn't work either

googling didn't help either, I've tried that without luck

I'm under the impression that it should be right in front of my eyes but I can't see why it breaks

Bert Belder

unread,
Jul 30, 2012, 4:29:38 PM7/30/12
to nod...@googlegroups.com

Are you adding a lot of watchers? Are there other processes running that have a lot of active file watchers?
ENOSPC happens when the kernel can't watch more files because you exceeded some limit. See http://linux.die.net/man/2/inotify_add_watch

Frederik Berg

unread,
Jul 30, 2012, 4:33:51 PM7/30/12
to nod...@googlegroups.com
... I once heard of this... in relation to dropbox (which I'm running)
I for myself add like 7 or 8 files but I'll look if dropbox is the matter

You probably gave me all the direction I need :) thank you
Reply all
Reply to author
Forward
0 new messages