Exponential back-off retries for retryable error without a specified … (#15684)

This commit is contained in:
Sehoon Shon
2025-12-29 17:23:23 -05:00
committed by GitHub
parent 10ae84869a
commit 07e597de40
3 changed files with 25 additions and 17 deletions
+9 -1
View File
@@ -220,6 +220,11 @@ export async function retryWithBackoff<T>(
if (classifiedError instanceof RetryableQuotaError || is500) {
if (attempt >= maxAttempts) {
const errorMessage =
classifiedError instanceof Error ? classifiedError.message : '';
debugLogger.warn(
`Attempt ${attempt} failed${errorMessage ? `: ${errorMessage}` : ''}. Max attempts reached`,
);
if (onPersistent429) {
try {
const fallbackModel = await onPersistent429(
@@ -240,7 +245,10 @@ export async function retryWithBackoff<T>(
: error;
}
if (classifiedError instanceof RetryableQuotaError) {
if (
classifiedError instanceof RetryableQuotaError &&
classifiedError.retryDelayMs !== undefined
) {
debugLogger.warn(
`Attempt ${attempt} failed: ${classifiedError.message}. Retrying after ${classifiedError.retryDelayMs}ms...`,
);