Skip to content

Commit 58cfb76

Browse files
gsquared94gemini-cli-robot
authored andcommitted
refactor: set max retry attempts to 3 (#11072)
# Conflicts: # packages/core/src/utils/retry.test.ts # packages/core/src/utils/retry.ts
1 parent 0612839 commit 58cfb76

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ describe('retryWithBackoff', () => {
9999
expect(mockFn).toHaveBeenCalledTimes(3);
100100
});
101101

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

106106
const promise = retryWithBackoff(mockFn);
107107

108108
// Expect it to fail with the error from the 5th attempt.
109+
<<<<<<< HEAD
109110
// eslint-disable-next-line vitest/valid-expect
110111
const assertionPromise = expect(promise).rejects.toThrow(
111112
'Simulated error attempt 5',
@@ -118,11 +119,24 @@ describe('retryWithBackoff', () => {
118119

119120
it('should default to 5 maxAttempts if options.maxAttempts is undefined', async () => {
120121
// This function will fail more than 5 times to ensure all retries are used.
122+
=======
123+
await Promise.all([
124+
expect(promise).rejects.toThrow('Simulated error attempt 3'),
125+
vi.runAllTimersAsync(),
126+
]);
127+
128+
expect(mockFn).toHaveBeenCalledTimes(3);
129+
});
130+
131+
it('should default to 3 maxAttempts if options.maxAttempts is undefined', async () => {
132+
// This function will fail more than 3 times to ensure all retries are used.
133+
>>>>>>> dd01af60 (refactor: set max retry attempts to 3 (#11072))
121134
const mockFn = createFailingFunction(10);
122135

123136
const promise = retryWithBackoff(mockFn, { maxAttempts: undefined });
124137

125138
// Expect it to fail with the error from the 5th attempt.
139+
<<<<<<< HEAD
126140
// eslint-disable-next-line vitest/valid-expect
127141
const assertionPromise = expect(promise).rejects.toThrow(
128142
'Simulated error attempt 5',
@@ -131,6 +145,14 @@ describe('retryWithBackoff', () => {
131145
await assertionPromise;
132146

133147
expect(mockFn).toHaveBeenCalledTimes(5);
148+
=======
149+
await Promise.all([
150+
expect(promise).rejects.toThrow('Simulated error attempt 3'),
151+
vi.runAllTimersAsync(),
152+
]);
153+
154+
expect(mockFn).toHaveBeenCalledTimes(3);
155+
>>>>>>> dd01af60 (refactor: set max retry attempts to 3 (#11072))
134156
});
135157

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

packages/core/src/utils/retry.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ export interface RetryOptions {
2929
}
3030

3131
const DEFAULT_RETRY_OPTIONS: RetryOptions = {
32+
<<<<<<< HEAD
3233
maxAttempts: 5,
34+
=======
35+
maxAttempts: 3,
36+
>>>>>>> dd01af60 (refactor: set max retry attempts to 3 (#11072))
3337
initialDelayMs: 5000,
3438
maxDelayMs: 30000, // 30 seconds
3539
shouldRetryOnError: defaultShouldRetry,

0 commit comments

Comments
 (0)