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;