Skip to content
Source
Sign inSign up
TanStack/db

fix(db): deduplicate loadedSubsets and join key requests #1554

Closedv-anton(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/1554/headopened

Showing 5 changed files with 39 additions and 20 deletions (loading 2).

x
0 of 5 viewed, 5 left
5 additions and 0 deletions.changeset/fix-loaded-subsets-dedup.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+"@tanstack/db": patch
+---
+​
+fix(db): prevent unbounded loadedSubsets growth in subscription and join lazy loading
24 additions and 18 deletionspackages/db/src/collection/subscription.tsModified
View file
@@ -4,6 +4,7 @@
import { EventEmitter } from '../event-emitter.js'
import { compileExpression } from '../query/compiler/evaluators.js'
import { buildCursor } from '../utils/cursor.js'
+import { isPredicateSubset } from '../query/predicate-utils.js'
import {
createFilterFunctionFromExpression,
createFilteredCallback,
@@ -376,17 +377,19 @@
orderBy: opts?.orderBy,
limit: opts?.limit,
- const syncResult = this.collection._sync.loadSubset(loadOptions)
+ // Check dedup BEFORE calling loadSubset to avoid sending duplicate requests
+ const isAlreadyCovered = this.loadedSubsets.some((existing) =>