From 0f9035b07e4f2350a66cfb8140dddfd83e0fda5e Mon Sep 17 00:00:00 2001 From: Emmanuel Quentin Date: Mon, 26 Feb 2024 13:09:10 -0500 Subject: [PATCH] Do not close websocket when already closed --- src/websocket-client.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/websocket-client.ts b/src/websocket-client.ts index 7044a73e..68c03e93 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -272,6 +272,11 @@ class WebSocketClient extends Emitter { return; } + if (this.socket.readyState === 3) { + logger.warn('Trying to close an already closed websocket, bailing.', { url: this._getUrl() }); + return; + } + this.socket.close(); this.initialized = false;