fix(runtime-fallback): extract status code from nested AI SDK errors
AI SDK wraps HTTP status codes inside error.error.statusCode (e.g., AI_APICallError). The current extractStatusCode only checks the top level, missing these nested codes. This caused runtime-fallback to skip retryable errors like 400, 500, 504 because it couldn't find the status code. Fixes #2617
This commit is contained in:
@@ -33,7 +33,7 @@ export function extractStatusCode(error: unknown, retryOnErrors?: number[]): num
|
||||
|
||||
const errorObj = error as Record<string, unknown>
|
||||
|
||||
const statusCode = errorObj.statusCode ?? errorObj.status ?? (errorObj.data as Record<string, unknown>)?.statusCode
|
||||
const statusCode = errorObj.statusCode ?? errorObj.status ?? (errorObj.data as Record<string, unknown>)?.statusCode ?? (errorObj.error as Record<string, unknown>)?.statusCode ?? (errorObj.cause as Record<string, unknown>)?.statusCode
|
||||
if (typeof statusCode === "number") {
|
||||
return statusCode
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user