From 68cdff5829589e32a95a5aca079a66a89c2b212d Mon Sep 17 00:00:00 2001 From: nacho Date: Thu, 11 Aug 2016 12:01:37 +0200 Subject: [PATCH] Avoid EPIPE error breaks execution on Handhake when socket already closed --- lib/WebSocketRequest.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/WebSocketRequest.js b/lib/WebSocketRequest.js index f4d96555..9a101115 100644 --- a/lib/WebSocketRequest.js +++ b/lib/WebSocketRequest.js @@ -447,6 +447,8 @@ WebSocketRequest.prototype.accept = function(acceptedProtocol, allowedOrigin, co cleanupFailedConnection(connection); } else { + // Avoid EPIPE error to break execution. Error is detected in callback + this.socket.on ('error', function (err) {}); this.socket.write(response, 'ascii', function(error) { if (error) { cleanupFailedConnection(connection);