From 1a4f33c69701fe6f4bbf0c6bdee2c48620de4612 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 19 Mar 2023 14:03:24 -0400 Subject: [PATCH] *Move _connectBackoff retry to costructor so we don't create duplicate hooks --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6496638..9981094 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,6 +40,10 @@ export class SwarmClient extends Client { strategy: "fibo", maxAttempts: Number.MAX_SAFE_INTEGER, }); + + this._connectBackoff.on("retry", (error: any) => { + this.logErr(error); + }); } get swarm(): number | undefined { @@ -83,10 +87,6 @@ export class SwarmClient extends Client { async start(): Promise { await this._connectBackoff.run(() => this.init()); - this._connectBackoff.on("retry", (error: any) => { - this.logErr(error); - }); - await this.ready(); }