Skip to content

Commit e2a1241

Browse files
committed
fix: remove queries without observers (cumulativeQueryHash)
1 parent f3816be commit e2a1241

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/query.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,9 @@ export class Query<
598598
predicate: (query) => {
599599
return (
600600
this.cumulativeQueryKeyHashesSet.has(query.options.queryHash!) &&
601-
query.observers.length === 1 &&
602-
query.observers[0] === this.queryObserver
601+
(query.observers.length === 0 ||
602+
(query.observers.length === 1 &&
603+
query.observers[0] === this.queryObserver))
603604
);
604605
},
605606
...params,
@@ -619,10 +620,14 @@ export class Query<
619620
remove(params?: QueryRemoveParams) {
620621
if (this.cumulativeQueryHash) {
621622
return this.queryClient.removeQueries({
622-
predicate: (query) =>
623-
this.cumulativeQueryKeyHashesSet.has(query.options.queryHash!) &&
624-
query.observers.length === 1 &&
625-
query.observers[0] === this.queryObserver,
623+
predicate: (query) => {
624+
return (
625+
this.cumulativeQueryKeyHashesSet.has(query.options.queryHash!) &&
626+
(query.observers.length === 0 ||
627+
(query.observers.length === 1 &&
628+
query.observers[0] === this.queryObserver))
629+
);
630+
},
626631
...params,
627632
});
628633
}

0 commit comments

Comments
 (0)