Skip to content

Commit 8959619

Browse files
kahirokunnmarkerikson
authored andcommitted
chore: rename shouldRetry to retryCondition
1 parent 0f62792 commit 8959619

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/toolkit/src/query/retry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface RetryOptions {
3737
* Callback to determine if a retry should be attempted.
3838
* Return `true` for another retry and `false` to quit trying prematurely.
3939
*/
40-
shouldRetry?: (error: FetchBaseQueryError, args: BaseQueryArg<BaseQueryFn>, extraArgs: {
40+
retryCondition?: (error: FetchBaseQueryError, args: BaseQueryArg<BaseQueryFn>, extraArgs: {
4141
attempt: number
4242
maxRetries: number
4343
baseQueryApi: BaseQueryApi
@@ -56,12 +56,12 @@ const retryWithBackoff: BaseQueryEnhancer<
5656
RetryOptions,
5757
RetryOptions | void
5858
> = (baseQuery, defaultOptions) => async (args, api, extraOptions) => {
59-
const defaultShouldRetry: Exclude<RetryOptions['shouldRetry'], undefined> = (_, __, {attempt, maxRetries}) => attempt <= maxRetries
59+
const defaultRetryCondition: Exclude<RetryOptions['retryCondition'], undefined> = (_, __, {attempt, maxRetries}) => attempt <= maxRetries
6060

6161
const options = {
6262
maxRetries: 5,
6363
backoff: defaultBackoff,
64-
shouldRetry: defaultShouldRetry,
64+
retryCondition: defaultRetryCondition,
6565
...defaultOptions,
6666
...extraOptions,
6767
}
@@ -87,7 +87,7 @@ const retryWithBackoff: BaseQueryEnhancer<
8787
throw e
8888
}
8989

90-
if (e instanceof HandledError && !options.shouldRetry(e.value as FetchBaseQueryError, args, {
90+
if (e instanceof HandledError && !options.retryCondition(e.value as FetchBaseQueryError, args, {
9191
attempt: retry,
9292
maxRetries: options.maxRetries,
9393
baseQueryApi: api,

0 commit comments

Comments
 (0)