Repository navigation
fix(query-core/queriesObserver): pass query hashes when combining in … - #12633
yashhbeladiya wants to merge 1 commit into
Conversation
…'#notify' so a stale combined result is not returned (TanStack#12626)
🦋 Changeset detectedLatest commit: aab2d96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 26 packages
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 |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…'#notify' so a stale combined result is not returned (#12626)
🎯 Changes
Fixes #12626
useQuerieswith a stablecombinecould hand back a combined result built from the previous query list. If a query from the old list updated between the render and the effect that callssetQueries,#notifyre-rancombineon the old results but didn't pass any query hashes. So#lastQueryHashesstill held the new list from the render. On the next render the hashes looked unchanged,#result === #lastResult, and the old (shorter) combined result was returned. That's how the reporter ended up withresults[index]beingundefined.The fix is a one-liner:
#notifynow passes the hashes of the queries it's actually combining (from#observerMatches). The next render sees that the list changed and recomputes. It doesn't add extracombinecalls, because#resulthas always just changed when#notifyruns.I added a test in
queriesObserver.test.tsxthat follows the same order asuseQueries: subscribe with one query, render with two, let the first query resolve beforesetQueriesruns, then render again. It fails onmain(gets 1 result instead of 2) and passes with the fix. TheuseQueriestests in react, preact, vue, solid, svelte and lit still pass.About
test:pr: everything passes except the Next.js example and integration builds. Those fail the same way onmain, because Next.js 16.4.4 refuses to build over a known security advisory (SecurityFatalError). That's unrelated to this change (the renovate PR #12558 bumps Next).✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit