Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Unexpected error occurs, during the watching #40

chamsae opened this Issue Mar 16, 2013 · 4 comments


None yet
2 participants

chamsae commented Mar 16, 2013

Hi, I'm using this module for watching folder.
but long time later on watching(I don't know exact time), unhandled error occurs and exit.
it is very fatal problem for me, server should not shutdown.
the last error message is below.

throw arguments[1]; // Unhandled 'error' event
Error: watch ECONNRESET
at errnoException (fs.js:806:11)
at FSEvent._handle.onchange (fs.js:824:26)

Process finished with exit code 1

do you know what is problem?
sourcefile about watchr is below.

var watchr = require('watchr');

var ftpWork = require('./ftpWork.js');

// Watch a directory or file
console.log('Watch our paths');
    paths: ['//HOCH-PC/Users/HOCH/Desktop/WatchTest'],
    listeners: {
         log: function(logLevel){
         console.log('a log message occured:', arguments);
         error: function(err){
         console.log('an error occured:', err);
        watching: function(err,watcherInstance,isWatching){
            if (err) {
                console.log("watching the path " + watcherInstance.path + " failed with error", err);
            } else {
                console.log("watching the path " + watcherInstance.path + " completed");
        change: function(changeType,filePath,fileCurrentStat,filePreviousStat){
            console.log("[ "+changeType+" ] "+filePath);

                var uploadFilename = filePath.split('\\').pop();
                console.log("---uploading file");

                ftpWork.ftpConnection.put(filePath, './galleryImage/'+uploadFilename, function(err){
                        console.log("====FTP file upload success?==");

    next: function(err,watchers){
        if (err) {
            return console.log("watching everything failed with error", err);
        } else {
            console.log('watching everything completed', watchers);

        // Close watchers after 60 seconds
         var i;
         console.log('Stop watching our paths');
         for ( i=0;  i<watchers.length; i++ ) {

chamsae commented Mar 17, 2013

nobody knows this?


balupton commented Apr 10, 2013

#41 is the same as this issue.

If you add an '.on('error',console.log)` to your watcher instance, do you still have the problem? Node will crash if error events go unhandled, and as watchr is constsantly watching files, it is likely to encounter the odd error here and there.

That being said, that will fix this error, but won't fix whatever caused the original error to be thrown. Once we know what the original error is we can then act on it. Probably best to follow that up in another issue dedicated to the specific error that is emitted.

@balupton balupton closed this Apr 10, 2013

chamsae commented Apr 10, 2013

balupton thanks! at that time, in the project, I couldn't watching network folder caused by this problem. then, I watched local folder, and network computer was generating files to my local folder. anyway, solved the project.
adding a '.on('error',console.log)' is a way to handle errors? I didn't know. when I would use this watchr module later, I will try that. thank you for commenting!


balupton commented Apr 10, 2013

Yeah, you just always gotta make sure you have an error event listener, it's fine if it doesn't do anything. Glad it helped :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment