From b3a8d5f86d7b785ca645c7584a5fe6eaa55f80c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 17 Jul 2021 15:30:56 +0200 Subject: [PATCH] reconnecter: clear timeout on connect. --- src/component/utils/reconnecter.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/component/utils/reconnecter.ts b/src/component/utils/reconnecter.ts index 4e96e425..44b38228 100644 --- a/src/component/utils/reconnecter.ts +++ b/src/component/utils/reconnecter.ts @@ -127,6 +127,11 @@ export class Reconnecter extends EventEmitter { } public close(error?: Error): void { + if (this._timeout) { + window.clearTimeout(this._timeout) + this._timeout = undefined + } + if (!this._open) { throw new Error('connection is already closed') } @@ -141,6 +146,11 @@ export class Reconnecter extends EventEmitter { } public connect(): void { + if (this._timeout) { + window.clearTimeout(this._timeout) + this._timeout = undefined + } + this._conn.connect() this._timeout = window.setTimeout(this.onDisconnect.bind(this), this._config.timeoutMs) }