fix(query-db): keep shared Query fetches alive for Collection owners #2158
Closed
KyleAMathews(GitHub profile, opens in a new tab)wants to merge 57 commits into
main fromcodex/query-db-published-core·opened Showing 39 changed files with 25 additions and 16 deletions (loading 36).
x
@@ -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.
@@ -429,14 +429,12 @@
-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`