From 83b1a485a35d59e319ae3574c037bcf0bf5a6034 Mon Sep 17 00:00:00 2001 From: Benoit Charbonnier Date: Tue, 1 Jul 2014 15:22:12 +0200 Subject: [PATCH] fix(server): Force clients disconnect on Windows It occurs that only on Windows, socket.io clients are not properly disconnected, which causes Karma to not exit immediately when everything is done. We have to wait for some internal disconnection socket.io event timeout. This PR basically check if all sockets are disconnected. If not we manually force the disconnection. Fixes #1109 --- lib/server.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index e3f6f9416..4e8bd40cd 100644 --- a/lib/server.js +++ b/lib/server.js @@ -197,7 +197,11 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file // TODO(vojta): change the client to not send the event (if disconnected by purpose) var sockets = socketServer.sockets.sockets; Object.getOwnPropertyNames(sockets).forEach(function(key) { - sockets[key].removeAllListeners('disconnect'); + var socket = sockets[key]; + socket.removeAllListeners('disconnect'); + if (!socket.disconnected) { + socket.disconnect(); + } }); var removeAllListenersDone = false;