From dbacf582a5907af75c6d424f017af39096ab0b93 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 5 Jul 2019 21:43:33 +0200 Subject: [PATCH] Revert "[minor] Remove unneeded `if` statement" This reverts commit 297f56df79f6bf4757465fb6b59884faf5b75337. --- lib/websocket.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/websocket.js b/lib/websocket.js index e17d6c1a7..cd8929bdc 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -901,6 +901,8 @@ function socketOnError() { this.removeListener('error', socketOnError); this.on('error', NOOP); - websocket.readyState = WebSocket.CLOSING; - this.destroy(); + if (websocket) { + websocket.readyState = WebSocket.CLOSING; + this.destroy(); + } }