@tanstack/query-core 5.90.14 → 5.90.15
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/mutation.cjs +16 -3
- package/build/legacy/mutation.cjs.map +1 -1
- package/build/legacy/mutation.js +16 -3
- package/build/legacy/mutation.js.map +1 -1
- package/build/legacy/mutationObserver.cjs +46 -30
- package/build/legacy/mutationObserver.cjs.map +1 -1
- package/build/legacy/mutationObserver.js +46 -30
- package/build/legacy/mutationObserver.js.map +1 -1
- package/build/legacy/query.cjs +4 -1
- package/build/legacy/query.cjs.map +1 -1
- package/build/legacy/query.js +4 -1
- package/build/legacy/query.js.map +1 -1
- package/build/modern/mutation.cjs +16 -3
- package/build/modern/mutation.cjs.map +1 -1
- package/build/modern/mutation.js +16 -3
- package/build/modern/mutation.js.map +1 -1
- package/build/modern/mutationObserver.cjs +42 -26
- package/build/modern/mutationObserver.cjs.map +1 -1
- package/build/modern/mutationObserver.js +42 -26
- package/build/modern/mutationObserver.js.map +1 -1
- package/build/modern/query.cjs +4 -1
- package/build/modern/query.cjs.map +1 -1
- package/build/modern/query.js +4 -1
- package/build/modern/query.js.map +1 -1
- package/package.json +1 -1
- package/src/mutation.ts +17 -3
- package/src/mutationObserver.ts +42 -26
- package/src/query.ts +3 -0
package/src/mutation.ts
CHANGED
|
@@ -278,14 +278,22 @@ export class Mutation<
|
|
|
278
278
|
this as Mutation<unknown, unknown, unknown, unknown>,
|
|
279
279
|
mutationFnContext,
|
|
280
280
|
)
|
|
281
|
+
} catch (e) {
|
|
282
|
+
void Promise.reject(e)
|
|
283
|
+
}
|
|
281
284
|
|
|
285
|
+
try {
|
|
282
286
|
await this.options.onError?.(
|
|
283
287
|
error as TError,
|
|
284
288
|
variables,
|
|
285
289
|
this.state.context,
|
|
286
290
|
mutationFnContext,
|
|
287
291
|
)
|
|
292
|
+
} catch (e) {
|
|
293
|
+
void Promise.reject(e)
|
|
294
|
+
}
|
|
288
295
|
|
|
296
|
+
try {
|
|
289
297
|
// Notify cache callback
|
|
290
298
|
await this.#mutationCache.config.onSettled?.(
|
|
291
299
|
undefined,
|
|
@@ -295,7 +303,11 @@ export class Mutation<
|
|
|
295
303
|
this as Mutation<unknown, unknown, unknown, unknown>,
|
|
296
304
|
mutationFnContext,
|
|
297
305
|
)
|
|
306
|
+
} catch (e) {
|
|
307
|
+
void Promise.reject(e)
|
|
308
|
+
}
|
|
298
309
|
|
|
310
|
+
try {
|
|
299
311
|
await this.options.onSettled?.(
|
|
300
312
|
undefined,
|
|
301
313
|
error as TError,
|
|
@@ -303,10 +315,12 @@ export class Mutation<
|
|
|
303
315
|
this.state.context,
|
|
304
316
|
mutationFnContext,
|
|
305
317
|
)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
this.#dispatch({ type: 'error', error: error as TError })
|
|
318
|
+
} catch (e) {
|
|
319
|
+
void Promise.reject(e)
|
|
309
320
|
}
|
|
321
|
+
|
|
322
|
+
this.#dispatch({ type: 'error', error: error as TError })
|
|
323
|
+
throw error
|
|
310
324
|
} finally {
|
|
311
325
|
this.#mutationCache.runNext(this)
|
|
312
326
|
}
|
package/src/mutationObserver.ts
CHANGED
|
@@ -172,33 +172,49 @@ export class MutationObserver<
|
|
|
172
172
|
} satisfies MutationFunctionContext
|
|
173
173
|
|
|
174
174
|
if (action?.type === 'success') {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
try {
|
|
176
|
+
this.#mutateOptions.onSuccess?.(
|
|
177
|
+
action.data,
|
|
178
|
+
variables,
|
|
179
|
+
onMutateResult,
|
|
180
|
+
context,
|
|
181
|
+
)
|
|
182
|
+
} catch (e) {
|
|
183
|
+
void Promise.reject(e)
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
this.#mutateOptions.onSettled?.(
|
|
187
|
+
action.data,
|
|
188
|
+
null,
|
|
189
|
+
variables,
|
|
190
|
+
onMutateResult,
|
|
191
|
+
context,
|
|
192
|
+
)
|
|
193
|
+
} catch (e) {
|
|
194
|
+
void Promise.reject(e)
|
|
195
|
+
}
|
|
188
196
|
} else if (action?.type === 'error') {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
try {
|
|
198
|
+
this.#mutateOptions.onError?.(
|
|
199
|
+
action.error,
|
|
200
|
+
variables,
|
|
201
|
+
onMutateResult,
|
|
202
|
+
context,
|
|
203
|
+
)
|
|
204
|
+
} catch (e) {
|
|
205
|
+
void Promise.reject(e)
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
this.#mutateOptions.onSettled?.(
|
|
209
|
+
undefined,
|
|
210
|
+
action.error,
|
|
211
|
+
variables,
|
|
212
|
+
onMutateResult,
|
|
213
|
+
context,
|
|
214
|
+
)
|
|
215
|
+
} catch (e) {
|
|
216
|
+
void Promise.reject(e)
|
|
217
|
+
}
|
|
202
218
|
}
|
|
203
219
|
}
|
|
204
220
|
|
package/src/query.ts
CHANGED
|
@@ -658,6 +658,9 @@ export class Query<
|
|
|
658
658
|
fetchFailureReason: error,
|
|
659
659
|
fetchStatus: 'idle',
|
|
660
660
|
status: 'error',
|
|
661
|
+
// flag existing data as invalidated if we get a background error
|
|
662
|
+
// note that "no data" always means stale so we can set unconditionally here
|
|
663
|
+
isInvalidated: true,
|
|
661
664
|
}
|
|
662
665
|
case 'invalidate':
|
|
663
666
|
return {
|