Wednesday, 19 April 2017

node-watch ECONNRESET on network drive

I have a small app that uses node-watch to watch 2 network drives and moves files between them when a change occurs. But the network often goes down, how do I prevent ECONNRESET crashes? The page for the package doesn't specify any error handling.

The code:

watch(directories.SQL_XML_IN, {
    recursive: false,
    filter: function (name) {
        return /\.xml$/i.test(name);
    }
}, function (evt, name) {
    if (evt == 'update') {
        // move files
    }
});

And the error:

events.js:141
  throw er; // Unhandled 'error' event
  ^

Error: watch null ECONNRESET
at exports._errnoException (util.js:870:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1217:21)



via d.a.vorm

No comments:

Post a Comment