diff --git a/packages/sdk/src/reliable_channel/retry_manager.ts b/packages/sdk/src/reliable_channel/retry_manager.ts index 00426fd854..199b0fa80d 100644 --- a/packages/sdk/src/reliable_channel/retry_manager.ts +++ b/packages/sdk/src/reliable_channel/retry_manager.ts @@ -24,9 +24,17 @@ export class RetryManager { const timeout = this.timeouts.get(id); if (timeout) { clearTimeout(timeout); + this.timeouts.delete(id); } } + public stopAllRetries(): void { + for (const [_id, timeout] of this.timeouts.entries()) { + clearTimeout(timeout); + } + this.timeouts.clear(); + } + public startRetries(id: string, retry: () => void | Promise): void { this.retry(id, retry, 0); } @@ -36,7 +44,7 @@ export class RetryManager { retry: () => void | Promise, attemptNumber: number ): void { - clearTimeout(this.timeouts.get(id)); + this.stopRetries(id); if (attemptNumber < this.maxRetryNumber) { const interval = setTimeout(() => { void retry();