From 923b1b02e01de96d84c3b34d2f931c4cfc2a6e25 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Fri, 22 Dec 2023 10:53:22 +0000 Subject: [PATCH] feat(): safer websocket timer cleanup --- src/websocket-client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/websocket-client.ts b/src/websocket-client.ts index ade0eeb..e8f0d5e 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -808,11 +808,11 @@ export class WebsocketClient extends EventEmitter { const wasOpen = this.wsStore.isWsOpen(wsKey); - this.getWs(wsKey)?.terminate(); - delete this.wsStore.get(wsKey, true).activePongTimer; this.clearPingTimer(wsKey); this.clearPongTimer(wsKey); + this.getWs(wsKey)?.terminate(); + if (!wasOpen) { this.logger.info( `${reason} - socket already closed - trigger immediate reconnect`,