diff --git a/lib/launchers/process.js b/lib/launchers/process.js index 067cfae87..55a3963e7 100644 --- a/lib/launchers/process.js +++ b/lib/launchers/process.js @@ -64,7 +64,7 @@ var ProcessLauncher = function(spawn, tempDir, timer) { var errorOutput = ''; - self._process.on('close', function(code) { + self._process.on('exit', function(code) { self._onProcessExit(code, errorOutput); }); diff --git a/lib/server.js b/lib/server.js index 79d733d95..569b8e0fb 100644 --- a/lib/server.js +++ b/lib/server.js @@ -204,7 +204,9 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file sockets.forEach(function(socket) { socket.removeAllListeners('disconnect'); if (!socket.disconnected) { - socket.disconnect(); + // Disconnect asynchronously. Socket.io mutates the `sockets.sockets` array + // underneath us so this would skip every other browser/socket. + process.nextTick(socket.disconnect.bind(socket)); } });