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);