Skip to content
Source
Sign inSign up
TanStack/query

React Query devtools restore loading action doesn't restore loading state, freezes tools #7176

Send to my agent
Closedtrevorfehrman(GitHub profile, opens in a new tab) opened this issue 6 comments

Describe the bug

When executing the Trigger Loading action in the devtools the query's status is successfully updated to "pending" and the nearest suspense boundary is successfully triggered. However when attempting to execute the Restore Loading action, the query's status is not reset and the dev tools become disabled.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-query-ensbun?file=src%2Findex.jsx

Steps to reproduce

  1. Click on the reopData query in the react query dev tools.
  2. Click on Trigger Loading. Observe the app is in its loading state and the query has a status of "pending"
  3. Click on Restore Loading. Observe the app remains in its loading state and the devtool action buttons become disabled.

Expected behavior

When I click Trigger Loading the query should go into it's "pending" state and trigger the nearest Suspense boundary. When I subsequently click Restore Loading the query's status should revert to success as it does when you Trigger and then Restore Error.

How often does this bug happen?

Every time

Screenshots or Videos

CleanShot 2024-03-25 at 23 57 15

Platform

OS: MacOS Browser: Arc 1.34.0 (47465) Chromium Engine Version 122.0.6261.129

Tanstack Query adapter

None

TanStack Query version

5.28.28

TypeScript version

No response

Additional context

Derived from a conversation on the Tanstack Discord: https://discord.com/channels/719702312431386674/1222015700370194452

  1. @ardeora can you have a look please? FYI, this is reproducible with normal useQuery as well, so it isn't suspense related imo

  2. TkDodo added labelsbug

  3. TkDodo added labelspackage: query-devtools

  4. Okay will take a look at it today!

  5. @TkDodo The change in #7008 broke this feature. This line specifically https://github.com/TanStack/query/pull/7008/files#diff-b5729917de14b1b87b04fa82d78a8abcafd81972cc9af9e8586ef27527d77ebbL332

    When we click Restore Loading we set the initial (user-defined) options back on the query but since data is undefined we do not end up cancelling the infinite fetch query set here and therefore the query is in a perpetual loading state. I have a workaround working but this would involve resetting the query which would reset some state like dataUpdatedCount back to 0. Maybe this should be the expected behavior anyway?

  6. yeah I think that's okay 👍

  7. Actually nevermind! Fixed it without needing the workaround! 😅

  8. Should be fixed in devtools v5.28.10+. Here is the reproduction with the new version https://stackblitz.com/edit/tanstack-query-baap5y?file=package.json that has been fixed

Sign in to join this conversation.