Cleanup and fix transient error detection in review
This commit is contained in:
@@ -86,6 +86,17 @@ describe("Transient Error Detector", () => {
|
||||
expect(isTransientError("Error: request was aborted")).toBe(true);
|
||||
});
|
||||
|
||||
it("matches 'operation was aborted' (DOMException-style abort errors)", () => {
|
||||
expect(isTransientError("operation was aborted")).toBe(true);
|
||||
expect(isTransientError("This operation was aborted")).toBe(true);
|
||||
expect(isTransientError("OPERATION WAS ABORTED")).toBe(true);
|
||||
});
|
||||
|
||||
it("does NOT match user-initiated 'operation was aborted by user'", () => {
|
||||
expect(isTransientError("The operation was aborted by user")).toBe(false);
|
||||
expect(isTransientError("operation was aborted by the signal")).toBe(false);
|
||||
});
|
||||
|
||||
// Edge cases
|
||||
it("returns false for empty string", () => {
|
||||
expect(isTransientError("")).toBe(false);
|
||||
|
||||
@@ -52,6 +52,10 @@ export const TRANSIENT_ERROR_PATTERNS: RegExp[] = [
|
||||
// AI provider abort errors — temporary request cancellations (e.g., Anthropic streaming aborts)
|
||||
// These occur when the provider's infrastructure drops an in-flight request.
|
||||
/request was aborted/i,
|
||||
// DOMException-style AbortError ("This operation was aborted"), emitted by fetch/
|
||||
// AbortController when a provider drops an in-flight operation. Excludes user-
|
||||
// initiated cancellations like "operation was aborted by user" — those are not transient.
|
||||
/operation was aborted(?!\s+by\b)/i,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -91,6 +95,7 @@ export function isTransientError(errorMessage: string): boolean {
|
||||
*/
|
||||
const SILENT_TRANSIENT_PATTERNS: RegExp[] = [
|
||||
/request was aborted/i,
|
||||
/operation was aborted(?!\s+by\b)/i,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user