Skip to content

Commit a1a2586

Browse files
committed
fix(swapclient): continue reconnection attempts
This fixes the logic around rescheduling reconnection attempts to ensure that they continue should the previous attempt to verify the connection fail. Closes #1240.
1 parent 43d778b commit a1a2586

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/swaps/SwapClient.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,13 @@ abstract class SwapClient extends EventEmitter {
120120
}
121121
if (this.status !== ClientStatus.Disabled) {
122122
if (!this.reconnectionTimer) {
123-
this.reconnectionTimer = setTimeout(this.verifyConnection, SwapClient.RECONNECT_TIMER);
124-
} else {
125-
this.reconnectionTimer.refresh();
123+
this.reconnectionTimer = setTimeout(async () => {
124+
await this.verifyConnection();
125+
if (!this.isConnected() && this.reconnectionTimer) {
126+
// if we were still not able to verify the connection, schedule another attempt
127+
this.reconnectionTimer.refresh();
128+
}
129+
}, SwapClient.RECONNECT_TIMER);
126130
}
127131
}
128132
}

0 commit comments

Comments
 (0)