-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The query gets stuck at fetching
status when re-fetched data has cycles
#6954
Comments
I will prepare a PR since the fix seems quite straightforward: add a |
maybe we need to make it more obvious in the docs, but for if that's not the case, you can:
I think this is something you would do in a custom |
however, I think the query should go into |
@TkDodo yeah, I think it should, because it took me some time to figure out what was the issue with the query, since I didn't know my data wasn't JSON-serializable |
got stuck with this problem for a long time too, would be good to get error in this case |
okay, does someone want to contribute this ? I think a try/catch around here: query/packages/query-core/src/query.ts Line 499 in e3240f0
|
Anyone on this? I think I'm encountering the same issue. For me it gets stuck in "fetching", this happens consistently. |
I think you can feel free to work on it. Putting the query in error state won't fix the problem for you though. What you likely want is to set |
Describe the bug
The query gets stuck at
fetching
status when you try to re-fetch data and it has cycles in it.Your minimal, reproducible example
https://codesandbox.io/p/sandbox/react-query-mfsz4x
Steps to reproduce
fetchStatus
gets stuck atfetching
Expected behavior
The query should change the
fetchStatus
toidle
when re-fetch has been finished.How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Tanstack Query adapter
react-query
TanStack Query version
v5.22.2
TypeScript version
No response
Additional context
As far as I understand, when you turn off
structuralSharing
for the query - the issue will go away.After some digging, I found that default
structuralSharing
functionality is to callreplaceEqualDeep
function. And when there are cycles in the data, this function goes into infinite loop because it recursively calls itself on each data property.The text was updated successfully, but these errors were encountered: