From c86bdb888a08a4b6f6575da8b6278ccda58e1e9d Mon Sep 17 00:00:00 2001 From: stanleyphu Date: Wed, 20 Dec 2023 11:12:57 -0800 Subject: [PATCH] Retry requests on more 50X status codes --- src/HttpClient.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HttpClient.ts b/src/HttpClient.ts index c4702a5..b572490 100644 --- a/src/HttpClient.ts +++ b/src/HttpClient.ts @@ -37,6 +37,7 @@ interface FetchRequestOptions { const MAX_RETRY_ATTEMPTS = 3; const BACKOFF_MULTIPLIER = 1.5; const MINIMUM_SLEEP_TIME = 500; +const RETRY_STATUS_CODES = [500, 502, 504]; const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) @@ -116,7 +117,7 @@ export default class ApiClient implements HttpClient { return true; } - if (response?.status == 502) { + if (response != null && RETRY_STATUS_CODES.includes(response.status)) { return true; }