From 99887e8fa63eeec90cb7f4540209b735daa55c34 Mon Sep 17 00:00:00 2001 From: Tina Wang Date: Thu, 4 Mar 2021 10:58:11 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20ECONNRESET=20unhandle=20er?= =?UTF-8?q?ror?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/WebSocket.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/WebSocket.js b/lib/WebSocket.js index 96955013b..0d239bd8e 100644 --- a/lib/WebSocket.js +++ b/lib/WebSocket.js @@ -478,6 +478,9 @@ function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) { // socket cleanup handlers socket.on('end', cleanupWebsocketResources.bind(this)); socket.on('close', cleanupWebsocketResources.bind(this)); + socket.on('error', function() { + try { socket.destroy(); } catch (e) {} + }); // ensure that the upgradeHead is added to the receiver function firstHandler(data) {