fix: add FreeUsageLimitError to RETRYABLE_ERROR_NAMES set (#2393)

This commit is contained in:
YeonGyu-Kim
2026-03-12 01:40:24 +09:00
parent 9eefbfe310
commit 079c6b17b0
2 changed files with 26 additions and 2 deletions

View File

@@ -82,4 +82,26 @@ describe("model-error-classifier", () => {
//#then
expect(provider).toBe("provider-x")
})
test("treats FreeUsageLimitError (lowercase) as retryable by name", () => {
//#given
const error = { name: "FreeUsageLimitError" }
//#when
const result = shouldRetryError(error)
//#then
expect(result).toBe(true)
})
test("treats freeusagelimiterror (lowercase name) as retryable by name", () => {
//#given
const error = { name: "freeusagelimiterror" }
//#when
const result = shouldRetryError(error)
//#then
expect(result).toBe(true)
})
})

View File

@@ -13,6 +13,7 @@ const RETRYABLE_ERROR_NAMES = new Set([
"ModelUnavailableError",
"ProviderConnectionError",
"AuthenticationError",
"freeusagelimiterror",
])
/**
@@ -97,12 +98,13 @@ export interface ErrorInfo {
export function isRetryableModelError(error: ErrorInfo): boolean {
// If we have an error name, check against known lists
if (error.name) {
const errorNameLower = error.name.toLowerCase()
// Explicit non-retryable takes precedence
if (NON_RETRYABLE_ERROR_NAMES.has(error.name)) {
if (NON_RETRYABLE_ERROR_NAMES.has(errorNameLower)) {
return false
}
// Check if it's a known retryable error
if (RETRYABLE_ERROR_NAMES.has(error.name)) {
if (RETRYABLE_ERROR_NAMES.has(errorNameLower)) {
return true
}
}