From f4100f621fbda534ba7e25c268b2875a36de03d4 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Sun, 24 Jul 2022 21:56:03 -0700 Subject: [PATCH] fix: (web3.js) clear the idle timer whenever the websocket closes (#26734) fix: clear the idle timer whenever the websocket closes --- web3.js/src/connection.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index f27a4b0a3..8c3e286ab 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -4577,6 +4577,10 @@ export class Connection { _wsOnClose(code: number) { this._rpcWebSocketConnected = false; this._rpcWebSocketGeneration++; + if (this._rpcWebSocketIdleTimeout) { + clearTimeout(this._rpcWebSocketIdleTimeout); + this._rpcWebSocketIdleTimeout = null; + } if (this._rpcWebSocketHeartbeat) { clearInterval(this._rpcWebSocketHeartbeat); this._rpcWebSocketHeartbeat = null;