Skip to content

Commit 3b822e9

Browse files
authored
refactor: set max retry attempts to 3 (#11072)
1 parent af43c78 commit 3b822e9

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,34 @@ describe('retryWithBackoff', () => {
9696
expect(mockFn).toHaveBeenCalledTimes(3);
9797
});
9898

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

103103
const promise = retryWithBackoff(mockFn);
104104

105105
// Expect it to fail with the error from the 5th attempt.
106106
await Promise.all([
107-
expect(promise).rejects.toThrow('Simulated error attempt 10'),
107+
expect(promise).rejects.toThrow('Simulated error attempt 3'),
108108
vi.runAllTimersAsync(),
109109
]);
110110

111-
expect(mockFn).toHaveBeenCalledTimes(10);
111+
expect(mockFn).toHaveBeenCalledTimes(3);
112112
});
113113

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

118118
const promise = retryWithBackoff(mockFn, { maxAttempts: undefined });
119119

120120
// Expect it to fail with the error from the 5th attempt.
121121
await Promise.all([
122-
expect(promise).rejects.toThrow('Simulated error attempt 10'),
122+
expect(promise).rejects.toThrow('Simulated error attempt 3'),
123123
vi.runAllTimersAsync(),
124124
]);
125125

126-
expect(mockFn).toHaveBeenCalledTimes(10);
126+
expect(mockFn).toHaveBeenCalledTimes(3);
127127
});
128128

129129
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
@@ -31,7 +31,7 @@ export interface RetryOptions {
3131
}
3232

3333
const DEFAULT_RETRY_OPTIONS: RetryOptions = {
34-
maxAttempts: 10,
34+
maxAttempts: 3,
3535
initialDelayMs: 5000,
3636
maxDelayMs: 30000, // 30 seconds
3737
shouldRetryOnError: defaultShouldRetry,

0 commit comments

Comments
 (0)