File tree 4 files changed +8
-8
lines changed
4 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ describe('query', () => {
155
155
const visibilityMock = mockVisibilityState ( 'hidden' )
156
156
157
157
let count = 0
158
- let result
158
+ let result : unknown
159
159
160
160
const promise = queryClient . fetchQuery ( {
161
161
queryKey : key ,
@@ -183,8 +183,10 @@ describe('query', () => {
183
183
// Check if the error is set to the cancelled error
184
184
try {
185
185
await promise
186
+ expect . unreachable ( )
186
187
} catch {
187
188
expect ( isCancelledError ( result ) ) . toBe ( true )
189
+ expect ( result instanceof Error ) . toBe ( true )
188
190
} finally {
189
191
// Reset visibilityState to original value
190
192
visibilityMock . mockRestore ( )
Original file line number Diff line number Diff line change @@ -577,19 +577,19 @@ export class Query<
577
577
} ) ,
578
578
}
579
579
case 'error' :
580
- const error = action . error as unknown
580
+ const error = action . error
581
581
582
582
if ( isCancelledError ( error ) && error . revert && this . #revertState) {
583
583
return { ...this . #revertState, fetchStatus : 'idle' }
584
584
}
585
585
586
586
return {
587
587
...state ,
588
- error : error as TError ,
588
+ error,
589
589
errorUpdateCount : state . errorUpdateCount + 1 ,
590
590
errorUpdatedAt : Date . now ( ) ,
591
591
fetchFailureCount : state . fetchFailureCount + 1 ,
592
- fetchFailureReason : error as TError ,
592
+ fetchFailureReason : error ,
593
593
fetchStatus : 'idle' ,
594
594
status : 'error' ,
595
595
}
Original file line number Diff line number Diff line change @@ -54,10 +54,11 @@ export function canFetch(networkMode: NetworkMode | undefined): boolean {
54
54
: true
55
55
}
56
56
57
- export class CancelledError {
57
+ export class CancelledError extends Error {
58
58
revert ?: boolean
59
59
silent ?: boolean
60
60
constructor ( options ?: CancelOptions ) {
61
+ super ( 'CancelledError' )
61
62
this . revert = options ?. revert
62
63
this . silent = options ?. silent
63
64
}
Original file line number Diff line number Diff line change @@ -100,9 +100,6 @@ export function useBaseQuery<
100
100
101
101
// Handle suspense
102
102
if ( shouldSuspend ( defaultedOptions , result ) ) {
103
- // Do the same thing as the effect right above because the effect won't run
104
- // when we suspend but also, the component won't re-mount so our observer would
105
- // be out of date.
106
103
throw fetchOptimistic ( defaultedOptions , observer , errorResetBoundary )
107
104
}
108
105
You can’t perform that action at this time.
0 commit comments