Skip to content
Source
Sign inSign up
TanStack/db

fix(db): nested toArray includes drop children when sibling groups share a correlation key (#1501) #1607

Mergedkevin-dp(GitHub profile, opens in a new tab)merged 17 commits intomain fromrefs/pull/1607/headmerged by kevin-dp(GitHub profile, opens in a new tab)

Showing 3 changed files with 9 additions and 0 deletions (loading 2).

x
0 of 3 viewed, 3 left
9 additions and 0 deletions.changeset/nested-toarray-shared-buffer-overlap.mdAdded
View file
@@ -0,0 +1,9 @@
+---
+'@tanstack/db': patch
+---
+​
+fix(db): keep deeply nested includes in sync when sibling groups share nested correlation keys
+​
+Deeply nested includes could drop or stop updating nested rows when sibling parent groups shared the same nested correlation key, especially when one sibling group was inserted after the initial load. Shared nested pipeline buffers were being drained through route state that was scoped too narrowly, so one branch could consume a buffered update before other branches that referenced the same nested row received it.
+​
+Nested route state is now shared at the same scope as the nested buffer and routes updates to every concrete destination branch before clearing the buffer. Snapshot replay still seeds late-arriving sibling groups with already-materialized rows, and recursive pending-change detection ensures deeper routed updates are flushed back up through the result tree.
packages/db/src/query/live/collection-config-builder.tsModified
View file
Loading the diff
packages/db/tests/query/includes.test.tsModified
View file