Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling resetPingTimeout on each ping #5537

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading