This commit is contained in:
Oren 2026-01-29 21:53:30 -05:00 committed by GitHub
commit b9190d1dcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -11,6 +11,7 @@ describe("failover-error", () => {
expect(resolveFailoverReasonFromError({ statusCode: "429" })).toBe("rate_limit"); expect(resolveFailoverReasonFromError({ statusCode: "429" })).toBe("rate_limit");
expect(resolveFailoverReasonFromError({ status: 403 })).toBe("auth"); expect(resolveFailoverReasonFromError({ status: 403 })).toBe("auth");
expect(resolveFailoverReasonFromError({ status: 408 })).toBe("timeout"); expect(resolveFailoverReasonFromError({ status: 408 })).toBe("timeout");
expect(resolveFailoverReasonFromError({ status: 400 })).toBe("format");
}); });
it("infers format errors from error messages", () => { it("infers format errors from error messages", () => {

View File

@ -120,6 +120,7 @@ export function resolveFailoverReasonFromError(err: unknown): FailoverReason | n
if (status === 429) return "rate_limit"; if (status === 429) return "rate_limit";
if (status === 401 || status === 403) return "auth"; if (status === 401 || status === 403) return "auth";
if (status === 408) return "timeout"; if (status === 408) return "timeout";
if (status === 400) return "format";
const code = (getErrorCode(err) ?? "").toUpperCase(); const code = (getErrorCode(err) ?? "").toUpperCase();
if (["ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "ECONNABORTED"].includes(code)) { if (["ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "ECONNABORTED"].includes(code)) {