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
The isRefetching signal on the query stays on true even when the query finishes refetching.
This issue happens when a disabled query is enabled and immediately refetched with the refetch method on the query and the data is fresh in the cache, it doesn't happen on stale queries.
This bug does not happen on version 5.16.1, I discovered it after updating from 5.16.1 to the latest version 5.17.19, I am not sure exactly which version introduced this bug.
Setting the id signal would enable the query and calling refetch immediately after will cause the bug to happen, but wrapping the refetch call in a setTimeout of even 0 delay would prevent the issue from happening
First, the id signal is changed. This schedules an effect to run inside the TanStack Query Angular adapter. Effects are asynchronous. Until this effect is run the query is not changed.
Second, refetch() is called on this unchanged query. It is disabled but refetch() can be used to run a disabled query manually. The queryKey will be just 'test' as id was an empty string when the query was instantiated.
Third, when the effect is run the query observer is given the new options including the new id signal value resulting in an updated query instance and queryFn is run.
Indeed the signals from Angular Query are not correct in this case which I did find a fix for but I have to check if that doesn't cause other issues. I am curious for the use case of both running refetch manually and enabling the query making it run automatically?
Thank you for the insight, this is indeed a rare issue, I found it in a component haphazardly refactored to use TanStack Query, I can't think of a real use case for something like this but it was improper usage of TanStack Query on my end that brought the issue to light.
Describe the bug
The
isRefetching
signal on the query stays ontrue
even when the query finishes refetching.This issue happens when a disabled query is enabled and immediately refetched with the
refetch
method on the query and the data is fresh in the cache, it doesn't happen on stale queries.This bug does not happen on version 5.16.1, I discovered it after updating from 5.16.1 to the latest version 5.17.19, I am not sure exactly which version introduced this bug.
For Example:
Setting the
id
signal would enable the query and callingrefetch
immediately after will cause the bug to happen, but wrapping therefetch
call in asetTimeout
of even 0 delay would prevent the issue from happeningYour minimal, reproducible example
https://github.com/shessafridi/angular-query-refetch-bug
Steps to reproduce
Repro Steps
isRefetching
state foreverExpected behavior
The query signals should reflect what is in the devtools
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
OS: Windows 11
Browser: Chrome
Angular Version: 17.0.0
Angular Query: 5.17.19
Tanstack Query adapter
angular-query
TanStack Query version
5.17.19
TypeScript version
~5.2.2
Additional context
No response
The text was updated successfully, but these errors were encountered: