From 02e23d4468be0737006bb91ec71f786fdcb90224 Mon Sep 17 00:00:00 2001 From: subaochen Date: Sat, 21 Mar 2026 11:33:28 +0800 Subject: [PATCH] fix: use Set instead of Array for fallback status codes Oxlint rule: should be a Set and use .has() for existence checks --- src/agents/failover-error.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/agents/failover-error.ts b/src/agents/failover-error.ts index ce6f3a3729c..bc053fd5e9e 100644 --- a/src/agents/failover-error.ts +++ b/src/agents/failover-error.ts @@ -337,7 +337,7 @@ export function coerceToFailoverError( * - Timeouts: 408 * - Not found: 404 (model may have been removed) */ -const DEFAULT_FALLBACK_STATUS_CODES = [408, 429, 500, 502, 503, 504, 404]; +const DEFAULT_FALLBACK_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504, 404]); /** * Check if an error should trigger fallback based on the configured error codes. @@ -365,13 +365,13 @@ export function shouldTriggerFallback( // Determine if status code should trigger fallback if (fallbackOnErrors === undefined || fallbackOnErrors === "default") { - return DEFAULT_FALLBACK_STATUS_CODES.includes(status); + return DEFAULT_FALLBACK_STATUS_CODES.has(status); } else if (fallbackOnErrors === "all") { // "all" means all HTTP errors (4xx and 5xx) return status >= 400; } else { // Custom list of status codes - return fallbackOnErrors.includes(status); + return new Set(fallbackOnErrors).has(status); } }