You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a bug in the returned value of useQueries when there are duplicate, unsorted queries, such as useQueries([ { queryKey: ['A'] }, { queryKey: ['B'] }, { queryKey: ['A'] }]. The current code returns [ QueryResult<'A'>, QueryResult<'A'>, QueryResult<'B'> ].
The root cause is due to a bug introduced here in the QueriesObserver's #findMatchingObservers method, where we always sort the results based on the queryHash.
Describe the bug
There is a bug in the returned value of
useQueries
when there are duplicate, unsorted queries, such asuseQueries([ { queryKey: ['A'] }, { queryKey: ['B'] }, { queryKey: ['A'] }]
. The current code returns[ QueryResult<'A'>, QueryResult<'A'>, QueryResult<'B'> ]
.The root cause is due to a bug introduced here in the
QueriesObserver
's#findMatchingObservers
method, where we always sort the results based on the queryHash.Your minimal, reproducible example
https://codesandbox.io/p/sandbox/dreamy-matsumoto-mc8jtm
Steps to reproduce
Another way to reproduce is through the unit test written in this pull request #8351
Expected behavior
We expect the input (Array) to #findMatchingObservers to match the output (Array)
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
This affects all operating systems/browsers
Tanstack Query adapter
None
TanStack Query version
5.59.6
TypeScript version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: