From a362b7b38289e777f6b75ef1c0bc6d1df459f3f1 Mon Sep 17 00:00:00 2001 From: Sehoon Shon Date: Fri, 30 Jan 2026 15:00:31 -0500 Subject: [PATCH] lower the default max retries to reduce contention (#17975) --- packages/core/src/utils/retry.test.ts | 22 +++++++++++----------- packages/core/src/utils/retry.ts | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/core/src/utils/retry.test.ts b/packages/core/src/utils/retry.test.ts index 7a70b45bb4..ff295d2028 100644 --- a/packages/core/src/utils/retry.test.ts +++ b/packages/core/src/utils/retry.test.ts @@ -101,33 +101,33 @@ describe('retryWithBackoff', () => { expect(mockFn).toHaveBeenCalledTimes(3); }); - it('should default to 10 maxAttempts if no options are provided', async () => { - // This function will fail more than 10 times to ensure all retries are used. - const mockFn = createFailingFunction(15); + it('should default to 3 maxAttempts if no options are provided', async () => { + // This function will fail more than 3 times to ensure all retries are used. + const mockFn = createFailingFunction(5); const promise = retryWithBackoff(mockFn); await Promise.all([ - expect(promise).rejects.toThrow('Simulated error attempt 10'), + expect(promise).rejects.toThrow('Simulated error attempt 3'), vi.runAllTimersAsync(), ]); - expect(mockFn).toHaveBeenCalledTimes(10); + expect(mockFn).toHaveBeenCalledTimes(3); }); - it('should default to 10 maxAttempts if options.maxAttempts is undefined', async () => { - // This function will fail more than 10 times to ensure all retries are used. - const mockFn = createFailingFunction(15); + it('should default to 3 maxAttempts if options.maxAttempts is undefined', async () => { + // This function will fail more than 3 times to ensure all retries are used. + const mockFn = createFailingFunction(5); const promise = retryWithBackoff(mockFn, { maxAttempts: undefined }); - // Expect it to fail with the error from the 10th attempt. + // Expect it to fail with the error from the 3rd attempt. await Promise.all([ - expect(promise).rejects.toThrow('Simulated error attempt 10'), + expect(promise).rejects.toThrow('Simulated error attempt 3'), vi.runAllTimersAsync(), ]); - expect(mockFn).toHaveBeenCalledTimes(10); + expect(mockFn).toHaveBeenCalledTimes(3); }); it('should not retry if shouldRetry returns false', async () => { diff --git a/packages/core/src/utils/retry.ts b/packages/core/src/utils/retry.ts index cbfa16379f..a0a8d48c80 100644 --- a/packages/core/src/utils/retry.ts +++ b/packages/core/src/utils/retry.ts @@ -40,7 +40,7 @@ export interface RetryOptions { } const DEFAULT_RETRY_OPTIONS: RetryOptions = { - maxAttempts: 10, + maxAttempts: 3, initialDelayMs: 5000, maxDelayMs: 30000, // 30 seconds shouldRetryOnError: isRetryableError,