failover: classify AbortError and stream-abort messages as timeout instead of unknown (#58315)

This commit is contained in:
yelog
2026-03-31 19:02:49 +08:00
committed by Altay
parent 75ab5bce6b
commit 1ed6e70b96
2 changed files with 17 additions and 0 deletions

View File

@@ -656,6 +656,18 @@ describe("isFailoverErrorMessage", () => {
]);
});
it("matches AbortError / stream-abort messages as timeout (#58315)", () => {
expectTimeoutFailoverSamples([
"The operation was aborted",
"This operation was aborted",
"the operation was aborted",
"stream closed",
"stream was closed",
"stream aborted",
"stream was aborted",
]);
});
it("matches Gemini MALFORMED_RESPONSE stop reason as timeout (#42149)", () => {
expectTimeoutFailoverSamples([
"Unhandled stop reason: MALFORMED_RESPONSE",

View File

@@ -63,6 +63,11 @@ const ERROR_PATTERNS = {
/\bstop reason:\s*(?:abort|error|malformed_response|network_error)\b/i,
/\breason:\s*(?:abort|error|malformed_response|network_error)\b/i,
/\bunhandled stop reason:\s*(?:abort|error|malformed_response|network_error)\b/i,
// AbortError messages from fetch/stream aborts (Ollama NDJSON stream
// timeouts, signal aborts, etc.) — without these the flattened message
// falls through to reason=unknown (#58315).
/\boperation was aborted\b/i,
/\bstream (?:was )?(?:closed|aborted)\b/i,
],
billing: [
/["']?(?:status|code)["']?\s*[:=]\s*402\b|\bhttp\s*402\b|\berror(?:\s+code)?\s*[:=]?\s*402\b|\b(?:got|returned|received)\s+(?:a\s+)?402\b|^\s*402\s+payment/i,