mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 22:55:13 +00:00
chore: do not retry the model request if the user has aborted the request (#11224)
This commit is contained in:
@@ -500,4 +500,25 @@ describe('retryWithBackoff', () => {
|
||||
expect(fallbackCallback).toHaveBeenCalledWith('oauth-personal');
|
||||
});
|
||||
});
|
||||
it('should abort the retry loop when the signal is aborted', async () => {
|
||||
const abortController = new AbortController();
|
||||
const mockFn = vi.fn().mockImplementation(async () => {
|
||||
const error: HttpError = new Error('Server error');
|
||||
error.status = 500;
|
||||
throw error;
|
||||
});
|
||||
|
||||
const promise = retryWithBackoff(mockFn, {
|
||||
maxAttempts: 5,
|
||||
initialDelayMs: 100,
|
||||
signal: abortController.signal,
|
||||
});
|
||||
await vi.advanceTimersByTimeAsync(50);
|
||||
abortController.abort();
|
||||
|
||||
await expect(promise).rejects.toThrow(
|
||||
expect.objectContaining({ name: 'AbortError' }),
|
||||
);
|
||||
expect(mockFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user