From 5d172151a2d3d652c6a2e089b09e6fca7f2aa50e Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Sun, 16 Oct 2022 23:33:28 -0700 Subject: [PATCH] fix: wrap _rpcWebSocketGeneration around when about to overflow (#28428) --- web3.js/src/connection.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index f5f113cda3..7794cbf3e6 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -5084,7 +5084,8 @@ export class Connection { */ _wsOnClose(code: number) { this._rpcWebSocketConnected = false; - this._rpcWebSocketGeneration++; + this._rpcWebSocketGeneration = + (this._rpcWebSocketGeneration + 1) % Number.MAX_SAFE_INTEGER; if (this._rpcWebSocketIdleTimeout) { clearTimeout(this._rpcWebSocketIdleTimeout); this._rpcWebSocketIdleTimeout = null;