Skip to content

Commit

Permalink
retry logic when retires mentioned
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Feb 17, 2024
1 parent ef8f1e8 commit 4fdb813
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/api/src/utils/client/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,16 @@ export class HttpClient implements IHttpClient {
opts: FetchOpts,
getBody: (res: Response) => Promise<T>
): Promise<{status: HttpStatusCode; body: T}> {
return retry(
async (_attempt) => {
return this.requestWithBodyWithFallbacks<T>(opts, getBody);
},
{retries: opts?.retryAttempts ?? 1, retryDelay: 200}
);
if (opts.retryAttempts !== undefined) {
return retry(
async (_attempt) => {
return this.requestWithBodyWithFallbacks<T>(opts, getBody);
},
{retries: opts.retryAttempts, retryDelay: 200}
);
} else {
return this.requestWithBodyWithFallbacks<T>(opts, getBody);
}
}

private async requestWithBodyWithFallbacks<T>(
Expand Down

0 comments on commit 4fdb813

Please sign in to comment.