Skip to content

Commit

Permalink
Retry requests on more 50X status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyphu committed Dec 20, 2023
1 parent 1f62681 commit c86bdb8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c86bdb8

Please sign in to comment.