From 7678923e04f917f065b721f0081750f779c1a0c1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 6 Jan 2025 13:25:29 +0000 Subject: [PATCH] Don't retry on 4xx responses (#4601) * Don't retry on 4xx responses I'm not sure why this was limited to a small set of 4xx responses. Nominally, no 4xx request should be retried (in fact the comment below says this, but then the code didn't quite match it). This was causing key backup requests to be retried even when the server responded 404 because the backup in question had been deleted, meaning the client would retry uselessly and it would take longer for the client to prompt the user for action. * Exclude 429s --- src/http-api/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/http-api/utils.ts b/src/http-api/utils.ts index d23e840bcd9..ef69c7e281a 100644 --- a/src/http-api/utils.ts +++ b/src/http-api/utils.ts @@ -180,8 +180,8 @@ export function calculateRetryBackoff(err: any, attempts: number, retryConnectio return -1; } - if (err.httpStatus && (err.httpStatus === 400 || err.httpStatus === 403 || err.httpStatus === 401)) { - // client error; no amount of retrying will save you now. + if (err.httpStatus && Math.floor(err.httpStatus / 100) === 4 && err.httpStatus !== 429) { + // client error; no amount of retrying will save you now (except for rate limiting which is handled below) return -1; }