From bc08fe1d03f7aa0381d7bdf9ed0541e05ac198f8 Mon Sep 17 00:00:00 2001 From: aandriushchenko Date: Fri, 6 Dec 2024 11:57:19 +0200 Subject: [PATCH 1/3] calling resetPingTimeout on each ping --- packages/core/src/controllers/relayer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/controllers/relayer.ts b/packages/core/src/controllers/relayer.ts index 28da2fc67..b1b82839b 100644 --- a/packages/core/src/controllers/relayer.ts +++ b/packages/core/src/controllers/relayer.ts @@ -19,7 +19,7 @@ import { Logger, } from "@walletconnect/logger"; import { RelayJsonRpc } from "@walletconnect/relay-api"; -import { FIVE_MINUTES, ONE_SECOND, THIRTY_SECONDS, toMiliseconds } from "@walletconnect/time"; +import { FIVE_MINUTES, FIVE_SECONDS, THIRTY_SECONDS, toMiliseconds } from "@walletconnect/time"; import { ICore, IMessageTracker, @@ -83,7 +83,7 @@ export class Relayer extends IRelayer { * the relay pings the client 30 seconds after the last message was received * meaning if we don't receive a message in 30 seconds, the connection can be considered dead */ - private heartBeatTimeout = toMiliseconds(THIRTY_SECONDS + ONE_SECOND); + private heartBeatTimeout = toMiliseconds(THIRTY_SECONDS + FIVE_SECONDS); private reconnectTimeout: NodeJS.Timeout | undefined; private connectPromise: Promise | undefined; private requestsInFlight: string[] = []; @@ -410,7 +410,7 @@ export class Relayer extends IRelayer { //@ts-expect-error - Types are divergent between the node and browser WS API if (this.provider?.connection?.socket) { //@ts-expect-error - this.provider?.connection?.socket?.once("ping", () => { + this.provider?.connection?.socket?.on("ping", () => { this.resetPingTimeout(); }); } From 98b5b918842ac21531cb783106b32dc8b24f38f4 Mon Sep 17 00:00:00 2001 From: Gancho Radkov <43912948+ganchoradkov@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:28:17 +0200 Subject: [PATCH 2/3] Update packages/core/src/controllers/relayer.ts --- packages/core/src/controllers/relayer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/controllers/relayer.ts b/packages/core/src/controllers/relayer.ts index f86af2276..ed4237953 100644 --- a/packages/core/src/controllers/relayer.ts +++ b/packages/core/src/controllers/relayer.ts @@ -19,7 +19,7 @@ import { Logger, } from "@walletconnect/logger"; import { RelayJsonRpc } from "@walletconnect/relay-api"; -import { FIVE_MINUTES, FIVE_SECONDS, THIRTY_SECONDS, toMiliseconds } from "@walletconnect/time"; +import { FIVE_MINUTES, ONE_SECOND, FIVE_SECONDS, THIRTY_SECONDS, toMiliseconds } from "@walletconnect/time"; import { ICore, IMessageTracker, From d2b825c1618c2c3547ecd47b06c54b7090bf82e3 Mon Sep 17 00:00:00 2001 From: Gancho Radkov <43912948+ganchoradkov@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:33:49 +0200 Subject: [PATCH 3/3] formatting --- packages/core/src/controllers/relayer.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/src/controllers/relayer.ts b/packages/core/src/controllers/relayer.ts index ed4237953..f251664f8 100644 --- a/packages/core/src/controllers/relayer.ts +++ b/packages/core/src/controllers/relayer.ts @@ -19,7 +19,13 @@ import { Logger, } from "@walletconnect/logger"; import { RelayJsonRpc } from "@walletconnect/relay-api"; -import { FIVE_MINUTES, ONE_SECOND, FIVE_SECONDS, THIRTY_SECONDS, toMiliseconds } from "@walletconnect/time"; +import { + FIVE_MINUTES, + ONE_SECOND, + FIVE_SECONDS, + THIRTY_SECONDS, + toMiliseconds, +} from "@walletconnect/time"; import { ICore, IMessageTracker,