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;