fix(runtime-fallback): honor retryable signal

This commit is contained in:
YeonGyu-Kim
2026-05-25 00:03:29 +09:00
parent de7f1d887d
commit 222adeb606
3 changed files with 176 additions and 0 deletions
@@ -97,6 +97,28 @@ export function extractErrorName(error: unknown): string | undefined {
return undefined
}
export function extractRetryableSignal(error: unknown): boolean | undefined {
if (!error || typeof error !== "object") return undefined
const errorObj = error as Record<string, unknown>
const paths = [
errorObj,
errorObj.data,
errorObj.error,
(errorObj.data as Record<string, unknown> | undefined)?.error,
errorObj.cause,
]
for (const obj of paths) {
if (obj && typeof obj === "object") {
const retryable = (obj as Record<string, unknown>).isRetryable
if (typeof retryable === "boolean") return retryable
}
}
return undefined
}
function isLocalizedQuotaExhaustionMessage(message: string): boolean {
return (
(/预扣费额度失败/i.test(message) && /用户剩余额度/i.test(message)) ||
@@ -199,5 +221,9 @@ export function isRetryableError(error: unknown, retryOnErrors: number[]): boole
return true
}
if (extractRetryableSignal(error) === true) {
return true
}
return RETRYABLE_ERROR_PATTERNS.some((pattern) => pattern.test(message))
}