fix(react-db): include peek-ahead item in useLiveInfiniteQuery initial query#1204
Draft
melvinhagberg wants to merge 1 commit intoTanStack:mainfrom
Draft
fix(react-db): include peek-ahead item in useLiveInfiniteQuery initial query#1204melvinhagberg wants to merge 1 commit intoTanStack:mainfrom
melvinhagberg wants to merge 1 commit intoTanStack:mainfrom
Conversation
…l query
The initial query was fetching exactly `pageSize` items, but the
peek-ahead logic requires `pageSize + 1` to determine if more pages
exist. This mismatch caused `hasNextPage` to incorrectly return `false`
on initial load when using SQLite predicate push-down with
`syncMode: "on-demand"`.
The issue occurred because:
1. Initial query loaded exactly `pageSize` items (e.g., 50)
2. `setWindow({ limit: pageSize + 1 })` tried to access the peek-ahead item
3. The item didn't exist yet, and lazy loading had timing issues
4. `hasNextPage` was incorrectly `false` even when more data existed
The fix aligns the initial query limit with what `setWindow` expects,
fetching `pageSize + 1` items upfront. The extra item is only used
internally for the `hasNextPage` check - the returned `data` is still
sliced to `pageSize` items via the existing useMemo logic.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6b8fded to
a78ec9e
Compare
🦋 Changeset detectedLatest commit: a78ec9e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The initial query was fetching exactly
pageSizeitems, but the peek-ahead logic requirespageSize + 1to determine if more pages exist. This mismatch causedhasNextPageto incorrectly returnfalseon initial load when using SQLite predicate push-down withsyncMode: "on-demand".The issue occurred because:
pageSizeitems (e.g., 50)setWindow({ limit: pageSize + 1 })tried to access the peek-ahead itemhasNextPagewas incorrectlyfalseeven when more data existedThe fix aligns the initial query limit with what
setWindowexpects, fetchingpageSize + 1items upfront. The extra item is only used internally for thehasNextPagecheck - the returneddatais still sliced topageSizeitems via the existing useMemo logic.🎯 Changes
✅ Checklist
pnpm test:pr.🚀 Release Impact