Skip to content

Comments

fix(react-db): handle rejected/stale setWindow promises in useLiveInfiniteQuery#1269

Open
sleitor wants to merge 2 commits intoTanStack:mainfrom
sleitor:fix/setWindow-promise-handling
Open

fix(react-db): handle rejected/stale setWindow promises in useLiveInfiniteQuery#1269
sleitor wants to merge 2 commits intoTanStack:mainfrom
sleitor:fix/setWindow-promise-handling

Conversation

@sleitor
Copy link

@sleitor sleitor commented Feb 18, 2026

Summary

The useEffect that calls utils.setWindow() in useLiveInfiniteQuery has three issues:

  1. No .catch() — if setWindow rejects (e.g. async loadSubset throws), isFetchingNextPage stays true forever with no error surfaced to the user.

  2. No cleanup for stale promises — if the effect re-runs while a previous setWindow promise is pending, the old .then() handler fires and sets isFetchingNextPage = false prematurely while new loading is in progress.

  3. Unhandled promise rejection — Node/browser logs an unhandled rejection warning.

Fix

  • Add .catch() that resets isFetchingNextPage and logs the error
  • Add a cancelled flag with useEffect cleanup to ignore stale promise settlements

Fixes #1240

…initeQuery

Three issues in the useEffect that calls setWindow():

1. No .catch() — if setWindow rejects, isFetchingNextPage stays true
   forever with no error surfaced.

2. No cleanup — if the effect re-runs while a previous promise is
   pending, the stale .then() can set isFetchingNextPage=false
   prematurely while new loading is in progress.

3. Unhandled promise rejection — the promise has no rejection handler,
   causing an unhandled rejection warning.

Add .catch() with error logging, a cancelled flag with useEffect
cleanup to ignore stale promise settlements.

Fixes TanStack#1240
@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

🦋 Changeset detected

Latest commit: bc1a705

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

This PR includes changesets to release 1 package
Name Type
@tanstack/react-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.

bug: useLiveInfiniteQuery Promise handling can leave isFetchingNextPage stuck

1 participant