Skip to content

Commit 684efc1

Browse files
committed
fix: support promise-response for shouldRetryOnError
1 parent ce25fec commit 684efc1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docs/interfaces/openapi_client.CommonHttpClientOptions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ ___
210210

211211
### shouldRetryOnError
212212

213-
`Optional` **shouldRetryOnError**: (`error`: `Error`, `attemptNumber`: `number`) => `boolean`
213+
`Optional` **shouldRetryOnError**: (`error`: `Error`, `attemptNumber`: `number`) => `boolean` \| `Promise`\<`boolean`\>
214214

215215
#### Type declaration
216216

217-
▸ (`error`, `attemptNumber`): `boolean`
217+
▸ (`error`, `attemptNumber`): `boolean` \| `Promise`\<`boolean`\>
218218

219219
Determine whether to retry on error.
220220

@@ -227,7 +227,7 @@ Determine whether to retry on error.
227227

228228
##### Returns
229229

230-
`boolean`
230+
`boolean` \| `Promise`\<`boolean`\>
231231

232232
## Methods
233233

src/schema-to-typescript/common/core/common-http-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface CommonHttpClientOptions {
7474
/**
7575
* Determine whether to retry on error.
7676
*/
77-
shouldRetryOnError?: (error: Error, attemptNumber: number) => boolean;
77+
shouldRetryOnError?: (error: Error, attemptNumber: number) => boolean | Promise<boolean>;
7878
}
7979

8080
/**
@@ -868,7 +868,7 @@ export class CommonHttpClient {
868868
}
869869
return fetchResponse;
870870
} catch (error) {
871-
if (!this.options.shouldRetryOnError?.(error as Error, attemptNumber)) {
871+
if (!(await this.options.shouldRetryOnError?.(error as Error, attemptNumber))) {
872872
throw error;
873873
}
874874
attemptNumber++;

0 commit comments

Comments
 (0)