Skip to content

Commit

Permalink
Merge pull request #5537 from paranormal/fix/relay-socket-on-ping
Browse files Browse the repository at this point in the history
calling resetPingTimeout on each ping
  • Loading branch information
ganchoradkov authored Dec 12, 2024
2 parents 2464e53 + d2b825c commit d80b097
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/core/src/controllers/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ 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,
ONE_SECOND,
FIVE_SECONDS,
THIRTY_SECONDS,
toMiliseconds,
} from "@walletconnect/time";
import {
ICore,
IMessageTracker,
Expand Down Expand Up @@ -86,7 +92,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<void> | undefined;
private requestsInFlight: string[] = [];
Expand Down Expand Up @@ -418,7 +424,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();
});
}
Expand Down

0 comments on commit d80b097

Please sign in to comment.