Skip to content
Source
Sign inSign up
TanStack/db

Keep Collection GC deadlines on a monotonic clock #1941

MergedKyleAMathewsmerged 6 commits intomain fromrefs/pull/1941/headmerged by KyleAMathews

Showing 7 changed files with 89 additions and 1 deletion (loading 4).

x
0 of 7 viewed, 7 left
5 additions and 0 deletions.changeset/fix-gc-clock.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/db': patch
+---
+​
+Use a monotonic clock for Collection garbage collection when available, so wall-clock changes do not delay or advance scheduled cleanup.
83 additions and 0 deletionsdocs/contributing/oracle-reviews/issue-1796-gc-clock.mdAdded
View file
@@ -0,0 +1,83 @@
+# Issue #1796: Collection GC clock review
+​
+Reviewed implementation: `39d68cd6` (base `ae2eb3fb`). This record covers the
+clock correction and oracle added at that commit. The source report is
+[issue #1796](https://github.com/TanStack/db/issues/1796); it had no comments
+when read on 2026-09-29. The full claim ledger is retained in the task record.
+​
+## Contract and bounded result
+​
+`BaseCollectionConfig.gcTime` promises collection cleanup after the configured
+number of milliseconds without active subscribers. `docs/guides/live-queries.md`
+documents the live-query variant. Where `performance.now()` is available and
+monotonic, moving the wall clock must not move an already scheduled GC deadline.
+The Collection's normal idle callback still follows the queue deadline.
+​
+The queue reads the current Performance clock for scheduling, timer selection,
+and processing. The previous `Date.now()` path remains the fallback where
+Performance is unavailable. That fallback still inherits backward wall-clock
+adjustments. Some browsers pause Performance time through OS sleep despite the
+intended monotonic-clock contract; this review did not test suspend/resume and
+does not claim sleep-inclusive GC timing.
+​