Skip to content
Source
Sign inSign up
TanStack/db

fix(query-db): keep shared Query fetches alive for Collection owners #2158

ClosedKyleAMathews(GitHub profile, opens in a new tab)wants to merge 57 commits intomain fromcodex/query-db-published-coreopened

Showing 39 changed files with 25 additions and 16 deletions (loading 36).

x
0 of 39 viewed, 39 left
9 additions and 0 deletions.changeset/query-db-published-core.mdAdded
View file
@@ -0,0 +1,9 @@
+---
+'@tanstack/query-db-collection': patch
+---
+​
+Keep a shared Query's provider signal live while another Collection acquisition owns it, and require an applied full-source result before reusing it for a narrower demand. Release the physical Query chosen by each acquisition when equal demands route differently after a failed full refresh or an explicit exact refetch. Order overlapping fetched row values by query-function invocation when cache callbacks start another Query first. Let a fresh server response replace an older persisted direct value after the original Collection acquisition releases. Remove observers and tracked Query cache entries when explicit Collection cleanup runs during a synchronous fetch notification.
+​
+Keep signal-free `loadSubsetOptions` cloneable and free of an enumerable signal property when passed to a query function.
+​
+Keep row ownership aligned with the active acquisition when a final release occurs during result application or synchronously starts a replacement acquisition. A replacement waits for an aborted but still-open commit before it applies the same Query result.
13 additions and 14 deletionsdocs/collections/query-collection.mdModified
View file
@@ -429,14 +429,12 @@
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
-same abort has no distinguishable cause and can also get that one retry.
+Use `ctx.signal` for the provider call. `ctx.meta.loadSubsetOptions.signal`