From 307be7a81ee1c08cbd1e2acf2ea98fbf26ae390d Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sat, 23 Jun 2018 17:35:16 +0200 Subject: [PATCH] [fix] Remove the `'data'` listener when the receiver emits an error --- lib/websocket.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/websocket.js b/lib/websocket.js index 4d7c4f15e..643124f20 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -693,6 +693,8 @@ function receiverOnDrain () { function receiverOnError (err) { const websocket = this[kWebSocket]; + websocket._socket.removeListener('data', socketOnData); + websocket.readyState = WebSocket.CLOSING; websocket._closeCode = err[constants.kStatusCode]; websocket.emit('error', err);