Skip to content
Source
Sign inSign up
TanStack/db

fix(db): keep a collection from garbage collection while its transaction persists #2258

MergedNabil372(GitHub profile, opens in a new tab)merged 14 commits intomain fromrefs/pull/2258/headmerged by KyleAMathews(GitHub profile, opens in a new tab)

Showing 30 changed files with 11 additions and 0 deletions (loading 28).

x
0 of 30 viewed, 30 left
5 additions and 0 deletions.changeset/gc-waits-for-persisting-transactions.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/db': patch
+---
+​
+Garbage collection no longer cleans up a collection while a transaction that touches it is persisting. Cleaning it up dropped the transaction's optimistic rows while its mutation handler still ran, and rejected waits such as Electric's `awaitTxId`, so a write could fail after the screen that made it unmounted. The `gcTime` delay now starts again when the last such transaction completes or fails, cancels obsolete queued idle cleanup, and preserves the remaining startup grace. Rolling back a manual transaction that stayed pending preserves the existing deadline. Explicit `cleanup()` still starts immediately; a transaction that settles afterward no longer restores another transaction's cleared optimistic rows.
6 additions and 0 deletions.github/workflows/e2e-tests.ymlModified
View file
@@ -114,6 +114,11 @@
working-directory: packages/db
run: pnpm test:indexed-db:browser
​
+ - name: Run Collection GC native idle oracle
+ if: matrix.group == 'browser'
+ working-directory: packages/db
+ run: pnpm test:collection-gc:browser
+​
- name: Upload IndexedDB oracle evidence
if: always() && matrix.group == 'browser'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
@@ -121,6 +126,7 @@
name: indexeddb-oracle-evidence
path: |