Describe the bug
In progressive sync mode, a collection queried directly with a where predicate loads the
matching subset first (fast path) and the rest of the collection in the background. But when the
same collection is fetched as a nested toArray child of another collection, there is no fast-path
step — the nested rows only become available once the entire child collection has finished its
background sync.
For example, querying posts directly, filtered to one user, shows that user's posts almost
immediately. Fetching the same posts as a nested child of that user shows them only after every post
of every user has loaded.
Reproducible with these tests:
Steps to Reproduce
// posts is an Electric collection with syncMode: 'progressive'
// Direct query — fast path works:
const direct = createLiveQueryCollection((q) =>
q.from({ post: posts }).where(({ post }) => eq(post.userId, userIdParam)),
);
// Nested query — no fast path:
const nested = createLiveQueryCollection((q) =>
q
.from({ user: users })
.where(({ user }) => eq(user.id, userIdParam))
.select(({ user }) => ({
...user,
posts: toArray(q.from({ post: posts }).where(({ post }) => eq(post.userId, user.id))),
})),
);
Observed Behavior
- The direct query loads the matching subset via the fast-path snapshot, then the rest in the
background.
- The nested query loads the whole
posts collection at once; the nested array stays empty until
the full background sync completes.
- No error or warning is thrown — the data is correct, just slow.
Expected Behavior
Fetching a collection as a nested toArray child should get the same progressive fast-path as
querying it directly: the matching subset should load first, the rest in the background.
Describe the bug
In
progressivesync mode, a collection queried directly with awherepredicate loads thematching subset first (fast path) and the rest of the collection in the background. But when the
same collection is fetched as a nested
toArraychild of another collection, there is no fast-pathstep — the nested rows only become available once the entire child collection has finished its
background sync.
For example, querying
postsdirectly, filtered to one user, shows that user's posts almostimmediately. Fetching the same posts as a nested child of that user shows them only after every post
of every user has loaded.
Reproducible with these tests:
packages/db/tests/query/progressive-includes-fastpath.test.tspackages/electric-db-collection/e2e/progressive-nested.e2e.test.tsSteps to Reproduce
Observed Behavior
background.
postscollection at once; the nested array stays empty untilthe full background sync completes.
Expected Behavior
Fetching a collection as a nested
toArraychild should get the same progressive fast-path asquerying it directly: the matching subset should load first, the rest in the background.