fix(failover): align abort timeout detection and regressions
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
coerceToFailoverError,
|
||||
describeFailoverError,
|
||||
isTimeoutError,
|
||||
resolveFailoverReasonFromError,
|
||||
} from "./failover-error.js";
|
||||
|
||||
@@ -27,6 +28,22 @@ describe("failover-error", () => {
|
||||
expect(resolveFailoverReasonFromError({ code: "ECONNRESET" })).toBe("timeout");
|
||||
});
|
||||
|
||||
it("infers timeout from abort stop-reason messages", () => {
|
||||
expect(resolveFailoverReasonFromError({ message: "Unhandled stop reason: abort" })).toBe(
|
||||
"timeout",
|
||||
);
|
||||
expect(resolveFailoverReasonFromError({ message: "stop reason: abort" })).toBe("timeout");
|
||||
expect(resolveFailoverReasonFromError({ message: "reason: abort" })).toBe("timeout");
|
||||
});
|
||||
|
||||
it("treats AbortError reason=abort as timeout", () => {
|
||||
const err = Object.assign(new Error("aborted"), {
|
||||
name: "AbortError",
|
||||
reason: "reason: abort",
|
||||
});
|
||||
expect(isTimeoutError(err)).toBe(true);
|
||||
});
|
||||
|
||||
it("coerces failover-worthy errors into FailoverError with metadata", () => {
|
||||
const err = coerceToFailoverError("credit balance too low", {
|
||||
provider: "anthropic",
|
||||
|
||||
Reference in New Issue
Block a user