Skip to content

Commit

Permalink
Merge pull request #3957 from reduxjs/retry-error-type
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed May 9, 2024
2 parents c892abd + c2cfd23 commit 72b3ac6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/toolkit/src/query/retry.ts
Expand Up @@ -2,6 +2,7 @@ import type {
BaseQueryApi,
BaseQueryArg,
BaseQueryEnhancer,
BaseQueryError,
BaseQueryExtraOptions,
BaseQueryFn,
} from './baseQueryTypes'
Expand Down Expand Up @@ -31,7 +32,7 @@ async function defaultBackoff(attempt: number = 0, maxRetries: number = 5) {
}

type RetryConditionFunction = (
error: FetchBaseQueryError,
error: BaseQueryError<BaseQueryFn>,
args: BaseQueryArg<BaseQueryFn>,
extraArgs: {
attempt: number
Expand Down
6 changes: 4 additions & 2 deletions packages/toolkit/src/query/tests/retry.test.ts
@@ -1,4 +1,5 @@
import type { BaseQueryFn } from '@reduxjs/toolkit/query'
import { vi } from 'vitest'
import type { BaseQueryFn, FetchBaseQueryError } from '@reduxjs/toolkit/query'
import { createApi, retry } from '@reduxjs/toolkit/query'
import { setupApiStore } from '../../tests/utils/helpers'

Expand Down Expand Up @@ -422,7 +423,8 @@ describe('configuration', () => {
m1: build.mutation({
query: () => ({ method: 'PUT' }),
extraOptions: {
retryCondition: (e) => e.data === 'hello retryCondition',
retryCondition: (e) =>
(e as FetchBaseQueryError).data === 'hello retryCondition',
},
}),
}),
Expand Down

0 comments on commit 72b3ac6

Please sign in to comment.