Skip to content
Source
Sign inSign up
TanStack/db

fix(query-db): reuse active full-source results for narrower demands #2135

MergedKyleAMathews(GitHub profile, opens in a new tab)merged 9 commits intomain fromrefs/pull/2135/headmerged by KyleAMathews(GitHub profile, opens in a new tab)

Showing 8 changed files with 92 additions and 0 deletions (loading 5).

x
0 of 8 viewed, 8 left
11 additions and 0 deletions.changeset/reuse-complete-query-source.mdAdded
View file
@@ -0,0 +1,11 @@
+---
+'@tanstack/query-db-collection': patch
+---
+​
+A completed, active full-source Query Collection load can now serve later
+filtered or windowed live queries when the collection uses a static query key.
+The narrower queries retain the full Query until their final owner releases,
+so the original full view can unmount without dropping their rows or stopping
+later invalidation updates. Incomplete full loads and explicit subset refetches
+keep their own request paths. A narrower scope with retained persisted ownership
+makes an exact request to revalidate its rows and owners.
21 additions and 0 deletionsdocs/collections/query-collection.mdModified
View file
@@ -429,6 +429,14 @@
cloning it; changing submitted data can make the request disagree with its cache
key. To change a query constant, supply a new value rather than mutating the old
one. Cancellation through the request's `AbortSignal` remains supported.
+Use `ctx.signal` for the provider call. A sole acquisition's first fetch keeps
+its supplied `loadSubsetOptions.signal`. Once acquisitions or Collections share
+a Query, later fetches expose the Query fetch signal there because the
+acquisition that installed the query function can release first. If a peer
+joins during a fetch and that original signal aborts, a provider rejection with
+its abort reason or an `AbortError` gets one retry with the live Query signal
+while the peer still owns the Query. An unrelated `AbortError` raised after the