Skip to content
Source
Sign inSign up
TanStack/db

fix: align persisted query retention fallback with effective gcTime #1400

Mergedsamwillis(GitHub profile, opens in a new tab)merged 8 commits intomain fromrefs/pull/1400/headmerged by samwillis(GitHub profile, opens in a new tab)

Showing 3 changed files with 47 additions and 24 deletions (loading 1).

x
0 of 3 viewed, 3 left
7 additions and 0 deletions.changeset/small-mice-fold.mdAdded
View file
@@ -0,0 +1,7 @@
+---
+'@tanstack/query-db-collection': patch
+---
+​
+fix: default persisted query retention to gcTime when omitted
+​
+When `persistedGcTime` is not provided, query collections now use the query's effective `gcTime` as the persisted retention TTL. This prevents unexpectedly early cleanup of persisted rows.
40 additions and 24 deletionspackages/query-db-collection/src/query.tsModified
View file
@@ -713,6 +713,7 @@
let syncStarted = false
let startupRetentionSettled = false
const retainedQueriesPendingRevalidation = new Set<string>()
+ const effectivePersistedGcTimes = new Map<string, number>()
const persistedRetentionTimers = new Map<
string,
ReturnType<typeof setTimeout>
@@ -1171,9 +1172,19 @@
Array<any>,
>(queryClient, observerOptions)
+ const resolvedQueryGcTime = queryClient.getQueryCache().find({