Skip to content

Commit cd5e6a6

Browse files
committed
commit to technically breaking change
1 parent 99066d8 commit cd5e6a6

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

packages/toolkit/src/query/fetchBaseQuery.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,12 @@ export function fetchBaseQuery({
302302
try {
303303
response = await fetchFn(request)
304304
} catch (e) {
305-
if (e instanceof DOMException && e.name === 'TimeoutError') {
306-
return {
307-
error: {
308-
status: 'TIMEOUT_ERROR',
309-
error: 'TIMEOUT_ERROR',
310-
},
311-
meta,
312-
}
313-
}
314305
return {
315306
error: {
316-
status: 'FETCH_ERROR',
307+
status:
308+
e instanceof DOMException && e.name === 'TimeoutError'
309+
? 'TIMEOUT_ERROR'
310+
: 'FETCH_ERROR',
317311
error: String(e),
318312
},
319313
meta,

packages/toolkit/src/query/tests/createApi.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ describe('timeout behavior', () => {
11971197

11981198
expect(result?.error).toEqual({
11991199
status: 'TIMEOUT_ERROR',
1200-
error: expect.stringMatching(/^AbortError:/),
1200+
error: expect.stringMatching(/^TimeoutError:/),
12011201
})
12021202
})
12031203
})

packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ describe('fetchBaseQuery', () => {
11921192

11931193
expect(result?.error).toEqual({
11941194
status: 'TIMEOUT_ERROR',
1195-
error: expect.stringMatching(/^AbortError:/),
1195+
error: expect.stringMatching(/^TimeoutError:/),
11961196
})
11971197
})
11981198
})
@@ -1559,7 +1559,7 @@ describe('timeout', () => {
15591559

15601560
expect(result?.error).toEqual({
15611561
status: 'TIMEOUT_ERROR',
1562-
error: expect.stringMatching(/^AbortError:/),
1562+
error: expect.stringMatching(/^TimeoutError:/),
15631563
})
15641564
})
15651565
})

0 commit comments

Comments
 (0)