Skip to content
Source
Sign inSign up
TanStack/db

fix: harden collection lifecycle and resume invariants #1785

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

Showing 29 changed files with 80 additions and 0 deletions (loading 25).

x
0 of 29 viewed, 29 left
17 additions and 0 deletions.changeset/calm-oracles-check-loss.mdAdded
View file
@@ -0,0 +1,17 @@
+---
+'@tanstack/db': patch
+'@tanstack/db-sqlite-persistence-core': patch
+'@tanstack/electric-db-collection': patch
+---
+​
+Harden Electric resume and lifecycle handling so partial updates cannot materialize unknown or moved-out rows, stale async work and waiters cannot cross cleanup or restart—including automatic garbage collection—and valid batches behave the same across callback partitions and persistence hydration.
+​
+Preserve hydrated baseline rows during persistence reloads, accept complete-row updates from explicit full-replica resumes, retain committed match evidence until reset, and restart persisted resumes when hydration completion cannot be verified.
+​
+Replace stale cached rows atomically when an invalid resume falls back to a fresh snapshot. Keep subset acquisitions from restoring logically removed rows, and isolate utilities and tag visibility when collection options are reused while preserving compatible same-collection resume state.
+​
+Accept partial updates to complete rows published independently by persistence, while preserving pending removal and reset boundaries. Avoid copying all applied keys at startup or each subset acquisition; presence checks overlay queued writes and buffered messages once per stream callback. Warn once when an older persistence adapter cannot verify hydration for safe resume.
+​
+Keep buffered tag move-outs inside the progressive snapshot's existing transaction so later live updates are not discarded behind an orphaned truncate.
+​
+Keep copied materialized configs and reentrant match callbacks scoped to their owning collection session. Cold tagged or legacy persisted state now recovers with a full snapshot behind cached rows, including in on-demand mode. Keep the reset marker through interrupted recovery and publish the replacement only after the full snapshot completes; known untagged and compatible warm resumes retain their saved offset.
23 additions and 0 deletionsAGENTS.mdModified
View file
@@ -390,6 +390,29 @@
the smallest test or oracle improvement that would catch the same class of bug,
not only the reported example.
​
+### Keep Oracles Independent