mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-08-09 16:36:40 -07:00
Reclassifying Capacity Exhaustion as Terminal Error (#28716)
This commit is contained in:
@@ -107,6 +107,36 @@ describe('Retry Utility Fallback Integration', () => {
|
||||
expect(mockApiCall).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
it('should call onPersistent429 immediately on attempt 1 when classifyGoogleError returns TerminalQuotaError', async () => {
|
||||
const mockApiCall = vi
|
||||
.fn()
|
||||
.mockRejectedValue(
|
||||
new TerminalQuotaError('Capacity exhausted', mockGoogleApiError),
|
||||
);
|
||||
|
||||
const mockPersistent429Callback = vi.fn(
|
||||
async () =>
|
||||
// Return null to stop retrying after fallback attempt
|
||||
null,
|
||||
);
|
||||
|
||||
const promise = retryWithBackoff(mockApiCall, {
|
||||
maxAttempts: 10, // High maxAttempts to prove we don't wait for max attempts
|
||||
initialDelayMs: 1,
|
||||
maxDelayMs: 10,
|
||||
onPersistent429: mockPersistent429Callback,
|
||||
authType: AuthType.LOGIN_WITH_GOOGLE,
|
||||
});
|
||||
|
||||
await expect(promise).rejects.toThrow('Capacity exhausted');
|
||||
expect(mockApiCall).toHaveBeenCalledTimes(1); // Only called once because it's terminal and fallback returned null
|
||||
expect(mockPersistent429Callback).toHaveBeenCalledTimes(1);
|
||||
expect(mockPersistent429Callback).toHaveBeenCalledWith(
|
||||
AuthType.LOGIN_WITH_GOOGLE,
|
||||
expect.any(TerminalQuotaError),
|
||||
);
|
||||
});
|
||||
|
||||
it('should trigger onPersistent429 when HTTP 499 persists through all retry attempts', async () => {
|
||||
let fallbackCalled = false;
|
||||
const mockError: HttpError = new Error('Simulated 499 error');
|
||||
|
||||
Reference in New Issue
Block a user