From d6d9c7cc74a00fc94a59c301c80ebdb1f3a44455 Mon Sep 17 00:00:00 2001 From: bbbugg Date: Sun, 25 Jan 2026 17:36:43 +0800 Subject: [PATCH] fix: add immediate retry abort for 429/503 status codes --- src/core/RequestHandler.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/RequestHandler.js b/src/core/RequestHandler.js index 7bd3822..1b53d8f 100644 --- a/src/core/RequestHandler.js +++ b/src/core/RequestHandler.js @@ -962,6 +962,17 @@ class RequestHandler { lastError = errorPayload; + // Check if we should stop retrying immediately based on status code + if ( + this.config.immediateSwitchStatusCodes && + this.config.immediateSwitchStatusCodes.includes(errorPayload.status) + ) { + this.logger.warn( + `[Request] Critical error ${errorPayload.status} detected (${errorPayload.message}), aborting retries immediately.` + ); + break; + } + // Log the warning for the current attempt this.logger.warn( `[Request] Attempt #${attempt}/${this.maxRetries} for request #${proxyRequest.request_id} failed: ${errorPayload.message}`