Skip to content
Permalink
Browse files

Do not silently swallow errors in event handlers; thanks to @ccoenen

…for the report
  • Loading branch information...
joliss committed May 21, 2015
1 parent c88fa29 commit 9923afe8f7c9ad7a05b5ebaf9a3233114214fdcd
Showing with 11 additions and 3 deletions.
  1. +2 −0 CHANGELOG.md
  2. +9 −3 lib/watcher.js
@@ -1,5 +1,7 @@
# master

* Do not silently swallow errors in change/error event handlers

# 0.16.2

* Add missing dependency
@@ -50,15 +50,21 @@ Watcher.prototype.check = function() {
printSlowTrees(hash.graph)
}
this.emit('change', hash)
}.bind(this), function(error) {
this.emit('error', error)
}.bind(this), function(err) {
this.emit('error', err)
if (Object.keys(self.watchedDirs).length === 0) {
console.error('An error occured before the first directory could be watched.')
console.error('Watcher quitting')
throw new Error('Error too early') // skip scheduling this.check
}
}.bind(this))
.then(this.check.bind(this))
.then(this.check.bind(this), function(err) {
// Errors here are usually due to errors in change/error event handlers
console.error('An unexpected error occurred. Watcher quitting.')
console.error(err.stack)
// Rethrow in case a debugging tool wants to catch it
throw err
})
} else {
setTimeout(this.check.bind(this), interval)
}

0 comments on commit 9923afe

Please sign in to comment.
You can’t perform that action at this time.