Skip to content

Commit 0f7fdd7

Browse files
committed
fix: wait for all queries to cancel
1 parent 765740d commit 0f7fdd7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/core/query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ export class Query<TData = unknown, TError = unknown, TQueryFnData = TData> {
541541
}
542542

543543
// Create callback to cancel this fetch
544-
this.cancelFetch = silent => {
545-
reject(new CancelledError(silent))
544+
this.cancelFetch = cancelOptions => {
545+
reject(new CancelledError(cancelOptions))
546546
cancelTransport?.()
547547
}
548548

src/core/queryClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ export class QueryClient {
147147
cancelOptions.revert = true
148148
}
149149

150-
notifyManager.batch(() => {
150+
const promises = notifyManager.batch(() =>
151151
this.cache.findAll(filters).map(query => query.cancel(cancelOptions))
152-
})
152+
)
153153

154-
return Promise.resolve().then(noop)
154+
return Promise.all(promises).then(noop).catch(noop)
155155
}
156156

157157
invalidateQueries(

0 commit comments

Comments
 (0)