From 07490a13c462172cc80f5c199da71b4bd6e7bdc9 Mon Sep 17 00:00:00 2001 From: domayorov Date: Tue, 6 Aug 2024 14:33:39 +0200 Subject: [PATCH] refactor(repeater): stop sending ping event --- .../repeater/src/lib/DefaultRepeaterServer.ts | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/packages/repeater/src/lib/DefaultRepeaterServer.ts b/packages/repeater/src/lib/DefaultRepeaterServer.ts index ade86a59..f2d626b2 100644 --- a/packages/repeater/src/lib/DefaultRepeaterServer.ts +++ b/packages/repeater/src/lib/DefaultRepeaterServer.ts @@ -62,20 +62,17 @@ interface SocketListeningEventMap { interface SocketEmitEventMap { [SocketEvents.DEPLOY]: (options: DeployCommandOptions) => void; [SocketEvents.UNDEPLOY]: () => void; - [SocketEvents.PING]: () => void; } @scoped(Lifecycle.ContainerScoped) @injectable() export class DefaultRepeaterServer implements RepeaterServer { private readonly MAX_DEPLOYMENT_TIMEOUT = 60_000; - private readonly MAX_PING_INTERVAL = 10_000; private readonly MAX_RECONNECTION_ATTEMPTS = 20; private readonly MIN_RECONNECTION_DELAY = 1000; private readonly MAX_RECONNECTION_DELAY = 86_400_000; private latestReconnectionError?: Error; - private pingTimer?: Timer; private connectionTimer?: Timer; private _socket?: Socket; private connectionAttempts = 0; @@ -104,7 +101,6 @@ export class DefaultRepeaterServer implements RepeaterServer { public disconnect() { this.events.removeAllListeners(); - this.clearPingTimer(); this.clearConnectionTimer(); this._socket?.disconnect(); @@ -128,8 +124,6 @@ export class DefaultRepeaterServer implements RepeaterServer { ) ]); - this.createPingTimer(); - return result; } @@ -336,8 +330,6 @@ export class DefaultRepeaterServer implements RepeaterServer { }; private handleDisconnect = (reason: string): void => { - this.clearPingTimer(); - if (reason !== 'io client disconnect') { this.events.emit(RepeaterServerEvents.DISCONNECTED); } @@ -356,19 +348,4 @@ export class DefaultRepeaterServer implements RepeaterServer { ); this.logger.error('An error occurred', error); } - - private createPingTimer() { - this.clearPingTimer(); - - this.pingTimer = setInterval( - () => this.socket.volatile.emit(SocketEvents.PING), - this.MAX_PING_INTERVAL - ).unref(); - } - - private clearPingTimer() { - if (this.pingTimer) { - clearInterval(this.pingTimer); - } - } }