Skip to content
Source
Sign inSign up
TanStack/query

fix(query-core): fix queriesObserver result and observer length mismatch #9973

Mergednwrahnema(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/9973/headmerged by TkDodo View on GitHub

Showing 2 changed files with 6 additions and 1 deletion.

x
0 of 2 viewed, 2 left
5 additions and 0 deletions.changeset/orange-flowers-post.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/query-core': patch
+---
+​
+fix useQueries race condition on queries length change (#9971)
1 addition and 1 deletionpackages/query-core/src/queriesObserver.tsModified
View file
@@ -106,7 +106,6 @@
const prevObservers = this.#observers
​
const newObserverMatches = this.#findMatchingObservers(this.#queries)
- this.#observerMatches = newObserverMatches
​
// set options for the new observers to notify of changes
newObserverMatches.forEach((match) =>
@@ -134,6 +133,7 @@
if (!hasStructuralChange && !hasResultChange) return
​
if (hasStructuralChange) {
+ this.#observerMatches = newObserverMatches
this.#observers = newObservers