Skip to content
Source
Sign inSign up
TanStack/db

fix(db-sqlite-persistence-core): answer a repeat subset acquisition synchronously #1859

ClosedMAST1999(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/1859/headopened

Showing 4 changed files with 5 additions and 0 deletions (loading 3).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/persisted-loadsubset-sync-fast-path.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/db-sqlite-persistence-core': patch
+---
+​
+Answer a repeat acquisition of an already-loaded subset synchronously. The persisted sync wrapper declared its `loadSubset` `async`, so it returned a promise even when the rows were already in the collection and the wrapped sync had answered `true`; a live query over such a subset was therefore never ready at construction, which left `useLiveSuspenseQuery` re-suspending without limit. Repeat acquisitions now skip the redundant store read, take a lease of their own so releasing a sibling cannot end one still in use, and fall back to the asynchronous path whenever the rows could have gone away — after a source truncate, after the last acquisition is released, during a reload, and before startup settles. Concurrent acquisitions of the same subset still read the store once each; sharing those is a separate change.
packages/db-sqlite-persistence-core/src/persisted.tsModified
View file
Loading the diff
packages/db-sqlite-persistence-core/tests/persisted.test.tsModified
View file
Loading the diff