Skip to content

Conversation

@melvinhagberg
Copy link

When using useLiveInfiniteQuery with syncMode: 'on-demand', navigating between different queries on the same collection causes the wrong data to appear on the first page.

This happens because a new subscription's first snapshot reads from the local index, which may contain data loaded by a different subscription's loadSubset call.

The fix tracks whether loadSubset has been called on a collection. When a new subscription's first snapshot runs:

  • If loadSubset has never been called, local data is from initial sync (valid for all queries)
  • If loadSubset has been called, local data may be contaminated, so we skip local reads and let loadSubset provide the correct data

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

When using useLiveInfiniteQuery with syncMode: 'on-demand', navigating
between different queries on the same collection causes the wrong data
to appear on the first page.

This happens because a new subscription's first snapshot reads from the
local index, which may contain data loaded by a different subscription's
loadSubset call.

The fix tracks whether loadSubset has been called on a collection. When
a new subscription's first snapshot runs:
- If loadSubset has never been called, local data is from initial sync
  (valid for all queries)
- If loadSubset has been called, local data may be contaminated, so we
  skip local reads and let loadSubset provide the correct data
@changeset-bot
Copy link

changeset-bot bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: c2b7c80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@tanstack/db Patch
@tanstack/angular-db Patch
@tanstack/electric-db-collection Patch
@tanstack/offline-transactions Patch
@tanstack/powersync-db-collection Patch
@tanstack/query-db-collection Patch
@tanstack/react-db Patch
@tanstack/rxdb-db-collection Patch
@tanstack/solid-db Patch
@tanstack/svelte-db Patch
@tanstack/trailbase-db-collection Patch
@tanstack/vue-db Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant