Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

restore-direct-write-no-refetch.md

8 lines1.8 KB

Prevent direct writes from automatically refetching active Query subsets. On-demand writes patch changed keys already present in active raw arrays or directly selected response arrays, except when the Query is shared with another Collection. Eager writes patch representable rows in a shared Query cache, so Collections using the same Query project those edits. In both modes, cache patches preserve Query error, invalidation, and freshness state; an idle eager cache seed moves from pending to success without advancing its freshness timestamp. Direct writes no longer clear a prior fetch error or mark stale data fresh. Older in-flight or queued results cannot undo an accepted write, and derived cache responses are not replayed over it on resubscribe. A later-started successful subset fetch controls a shared row's value over an older request that settles afterward. Callers choose when to request current server rows; a complete matching on-demand result can remove an omitted ownerless direct row. Query Core 5.90.15 or later is required for post-write refetch replacement and error-state recovery.

An eager Collection that later joins a Query patched by another eager Collection projects the cached edit without starting a request, including when disabled. An on-demand Collection still revalidates an unverified cache edit before accepting it for a subset. A fresh persisted Collection refetches on a cached-row collision when it cannot recover the order of its stored direct write and that Query result. Inactive Query entries under the Collection key prefix may be removed after a direct write. A physical Query whose stored key is outside that prefix remains in the cache, even when a custom hash aliases it with a Collection key; callers can explicitly evict or refetch that entry.