Skip to content

Commit 0f8d41c

Browse files
authored
lower the default max retries to reduce contention (#17975)
1 parent 7a947a2 commit 0f8d41c

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

packages/core/src/utils/retry.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,33 @@ describe('retryWithBackoff', () => {
101101
expect(mockFn).toHaveBeenCalledTimes(3);
102102
});
103103

104-
it('should default to 10 maxAttempts if no options are provided', async () => {
105-
// This function will fail more than 10 times to ensure all retries are used.
106-
const mockFn = createFailingFunction(15);
104+
it('should default to 3 maxAttempts if no options are provided', async () => {
105+
// This function will fail more than 3 times to ensure all retries are used.
106+
const mockFn = createFailingFunction(5);
107107

108108
const promise = retryWithBackoff(mockFn);
109109

110110
await Promise.all([
111-
expect(promise).rejects.toThrow('Simulated error attempt 10'),
111+
expect(promise).rejects.toThrow('Simulated error attempt 3'),
112112
vi.runAllTimersAsync(),
113113
]);
114114

115-
expect(mockFn).toHaveBeenCalledTimes(10);
115+
expect(mockFn).toHaveBeenCalledTimes(3);
116116
});
117117

118-
it('should default to 10 maxAttempts if options.maxAttempts is undefined', async () => {
119-
// This function will fail more than 10 times to ensure all retries are used.
120-
const mockFn = createFailingFunction(15);
118+
it('should default to 3 maxAttempts if options.maxAttempts is undefined', async () => {
119+
// This function will fail more than 3 times to ensure all retries are used.
120+
const mockFn = createFailingFunction(5);
121121

122122
const promise = retryWithBackoff(mockFn, { maxAttempts: undefined });
123123

124-
// Expect it to fail with the error from the 10th attempt.
124+
// Expect it to fail with the error from the 3rd attempt.
125125
await Promise.all([
126-
expect(promise).rejects.toThrow('Simulated error attempt 10'),
126+
expect(promise).rejects.toThrow('Simulated error attempt 3'),
127127
vi.runAllTimersAsync(),
128128
]);
129129

130-
expect(mockFn).toHaveBeenCalledTimes(10);
130+
expect(mockFn).toHaveBeenCalledTimes(3);
131131
});
132132

133133
it('should not retry if shouldRetry returns false', async () => {

packages/core/src/utils/retry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface RetryOptions {
4040
}
4141

4242
const DEFAULT_RETRY_OPTIONS: RetryOptions = {
43-
maxAttempts: 10,
43+
maxAttempts: 3,
4444
initialDelayMs: 5000,
4545
maxDelayMs: 30000, // 30 seconds
4646
shouldRetryOnError: isRetryableError,

0 commit comments

Comments
 (0)