From 2c389311ce683646675adccf5a7b7b3160335148 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Sat, 12 Apr 2014 13:26:24 +0100 Subject: [PATCH] fix: don't crash/terminate upon errors within chokidar Handle errors from chokidar and route them to the console. Previously, these unhandled errors (which are very common when editing in Visual Studio) would cause karma to terminate and all browsers to vanish. Fixes #959 --- lib/watcher.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/watcher.js b/lib/watcher.js index 78ae30adc..f5de7e99b 100644 --- a/lib/watcher.js +++ b/lib/watcher.js @@ -94,7 +94,12 @@ exports.watch = function(patterns, excludes, fileList, usePolling) { // register events chokidarWatcher.on('add', bind(fileList.addFile)) .on('change', bind(fileList.changeFile)) - .on('unlink', bind(fileList.removeFile)); + .on('unlink', bind(fileList.removeFile)) + // If we don't subscribe; unhandled errors from Chokidar will bring Karma down + // (see GH Issue #959) + .on('error', function(e) { + log.debug(e); + }); return chokidarWatcher; };