@tanstack/query-core 5.85.4 → 5.85.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/{hydration-QvU7ROZT.d.cts → hydration-DTop62kY.d.cts} +1 -1
- package/build/legacy/{hydration-D0MPgBG9.d.ts → hydration-Dh_94ejg.d.ts} +1 -1
- package/build/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/queriesObserver.d.cts +1 -1
- package/build/legacy/queriesObserver.d.ts +1 -1
- package/build/legacy/query.cjs +9 -5
- package/build/legacy/query.cjs.map +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/query.js +9 -5
- package/build/legacy/query.js.map +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryObserver.cjs +7 -5
- package/build/legacy/queryObserver.cjs.map +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/queryObserver.js +7 -5
- package/build/legacy/queryObserver.js.map +1 -1
- package/build/legacy/retryer.cjs +3 -2
- package/build/legacy/retryer.cjs.map +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/retryer.js +3 -2
- package/build/legacy/retryer.js.map +1 -1
- package/build/legacy/streamedQuery.d.cts +1 -1
- package/build/legacy/streamedQuery.d.ts +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/modern/{hydration-QvU7ROZT.d.cts → hydration-DTop62kY.d.cts} +1 -1
- package/build/modern/{hydration-D0MPgBG9.d.ts → hydration-Dh_94ejg.d.ts} +1 -1
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/queriesObserver.d.cts +1 -1
- package/build/modern/queriesObserver.d.ts +1 -1
- package/build/modern/query.cjs +9 -5
- package/build/modern/query.cjs.map +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/query.js +9 -5
- package/build/modern/query.js.map +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryObserver.cjs +7 -5
- package/build/modern/queryObserver.cjs.map +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/queryObserver.js +7 -5
- package/build/modern/queryObserver.js.map +1 -1
- package/build/modern/retryer.cjs +3 -2
- package/build/modern/retryer.cjs.map +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/retryer.js +3 -2
- package/build/modern/retryer.js.map +1 -1
- package/build/modern/streamedQuery.d.cts +1 -1
- package/build/modern/streamedQuery.d.ts +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/query.ts +10 -6
- package/src/queryObserver.ts +11 -5
- package/src/retryer.ts +4 -3
package/src/query.ts
CHANGED
|
@@ -507,7 +507,15 @@ export class Query<
|
|
|
507
507
|
| Promise<TData>
|
|
508
508
|
| undefined,
|
|
509
509
|
fn: context.fetchFn as () => Promise<TData>,
|
|
510
|
-
|
|
510
|
+
onCancel: (error) => {
|
|
511
|
+
if (error instanceof CancelledError && error.revert) {
|
|
512
|
+
this.setState({
|
|
513
|
+
...this.#revertState,
|
|
514
|
+
fetchStatus: 'idle' as const,
|
|
515
|
+
})
|
|
516
|
+
}
|
|
517
|
+
abortController.abort()
|
|
518
|
+
},
|
|
511
519
|
onFail: (failureCount, error) => {
|
|
512
520
|
this.#dispatch({ type: 'failed', failureCount, error })
|
|
513
521
|
},
|
|
@@ -550,13 +558,9 @@ export class Query<
|
|
|
550
558
|
if (error instanceof CancelledError) {
|
|
551
559
|
if (error.silent) {
|
|
552
560
|
// silent cancellation implies a new fetch is going to be started,
|
|
553
|
-
// so we
|
|
561
|
+
// so we piggyback onto that promise
|
|
554
562
|
return this.#retryer.promise
|
|
555
563
|
} else if (error.revert) {
|
|
556
|
-
this.setState({
|
|
557
|
-
...this.#revertState,
|
|
558
|
-
fetchStatus: 'idle' as const,
|
|
559
|
-
})
|
|
560
564
|
// transform error into reverted state data
|
|
561
565
|
// if the initial fetch was cancelled, we have no data, so we have
|
|
562
566
|
// to get reject with a CancelledError
|
package/src/queryObserver.ts
CHANGED
|
@@ -82,11 +82,6 @@ export class QueryObserver<
|
|
|
82
82
|
this.#client = client
|
|
83
83
|
this.#selectError = null
|
|
84
84
|
this.#currentThenable = pendingThenable()
|
|
85
|
-
if (!this.options.experimental_prefetchInRender) {
|
|
86
|
-
this.#currentThenable.reject(
|
|
87
|
-
new Error('experimental_prefetchInRender feature flag is not enabled'),
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
85
|
|
|
91
86
|
this.bindMethods()
|
|
92
87
|
this.setOptions(options)
|
|
@@ -272,6 +267,17 @@ export class QueryObserver<
|
|
|
272
267
|
get: (target, key) => {
|
|
273
268
|
this.trackProp(key as keyof QueryObserverResult)
|
|
274
269
|
onPropTracked?.(key as keyof QueryObserverResult)
|
|
270
|
+
if (
|
|
271
|
+
key === 'promise' &&
|
|
272
|
+
!this.options.experimental_prefetchInRender &&
|
|
273
|
+
this.#currentThenable.status === 'pending'
|
|
274
|
+
) {
|
|
275
|
+
this.#currentThenable.reject(
|
|
276
|
+
new Error(
|
|
277
|
+
'experimental_prefetchInRender feature flag is not enabled',
|
|
278
|
+
),
|
|
279
|
+
)
|
|
280
|
+
}
|
|
275
281
|
return Reflect.get(target, key)
|
|
276
282
|
},
|
|
277
283
|
})
|
package/src/retryer.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { CancelOptions, DefaultError, NetworkMode } from './types'
|
|
|
10
10
|
interface RetryerConfig<TData = unknown, TError = DefaultError> {
|
|
11
11
|
fn: () => TData | Promise<TData>
|
|
12
12
|
initialPromise?: Promise<TData>
|
|
13
|
-
|
|
13
|
+
onCancel?: (error: TError) => void
|
|
14
14
|
onFail?: (failureCount: number, error: TError) => void
|
|
15
15
|
onPause?: () => void
|
|
16
16
|
onContinue?: () => void
|
|
@@ -86,9 +86,10 @@ export function createRetryer<TData = unknown, TError = DefaultError>(
|
|
|
86
86
|
|
|
87
87
|
const cancel = (cancelOptions?: CancelOptions): void => {
|
|
88
88
|
if (!isResolved()) {
|
|
89
|
-
|
|
89
|
+
const error = new CancelledError(cancelOptions) as TError
|
|
90
|
+
reject(error)
|
|
90
91
|
|
|
91
|
-
config.
|
|
92
|
+
config.onCancel?.(error)
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
const cancelRetry = () => {
|