Fix stale data on host details page after subsequent navigations#40603
Merged
Fix stale data on host details page after subsequent navigations#40603
Conversation
nulmete
commented
Feb 26, 2026
| () => hostAPI.getMdm(hostIdFromURL), | ||
| { | ||
| enabled: !!hostIdFromURL, | ||
| refetchOnMount: false, |
Member
Author
There was a problem hiding this comment.
Removing refetchOnMount: false is the fix.
However, I decided to remove all refetchXXX: false props
IMO, it's good UX to have data sync after users had the tab opened for a long time and they come back (e.g. if they switched to another task).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #40603 +/- ##
=======================================
Coverage 66.28% 66.28%
=======================================
Files 2466 2466
Lines 197534 197534
Branches 8638 8638
=======================================
Hits 130945 130945
Misses 54739 54739
Partials 11850 11850
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cdcme
approved these changes
Feb 26, 2026
nulmete
added a commit
that referenced
this pull request
Feb 26, 2026
) <!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #40408 Part of the root cause for this issue is this commit: 5136d40 In summary, I moved the QueryClient instantiation out of AppWrapper because it needs to be a stable reference. I realized this was necessary when manipulating react-query's cache as part of that work. (I was debugging react-query's cache using **getQueryData** and it was always returning **undefined** for every entry -- that was fixed by doing what I described just above). When QueryClient was re-created on each AppWrapper mount, refetchOnMount: false had no effect.. there was never cached data to serve, so useQuery always fetched on every navigation to the host details page. After moving it out of AppWrapper, refetchOnMount: false works as expected and the cached (stale) data is served instead of refetching. The fix removes the refetchOnMount: false, refetchOnReconnect: false, and refetchOnWindowFocus: false overrides, restoring react-query's defaults so data is refreshed on navigation, tab focus, and reconnect. # Checklist for submitter - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [x] QA'd all new/changed functionality manually https://github.com/user-attachments/assets/fa3f90ef-46f4-4a30-acc6-2176a22e8299 For unreleased bug fixes in a release candidate, one of: - [x] Confirmed that the fix is not expected to adversely impact load test results - [ ] Alerted the release DRI if additional load testing is needed
nulmete
added a commit
that referenced
this pull request
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: Resolves #40408
Part of the root cause for this issue is this commit: 5136d40
In summary, I moved the QueryClient instantiation out of AppWrapper because it needs to be a stable reference. I realized this was necessary when manipulating react-query's cache as part of that work.
(I was debugging react-query's cache using getQueryData and it was always returning undefined for every entry -- that was fixed by doing what I described just above).
When QueryClient was re-created on each AppWrapper mount, refetchOnMount: false had no effect.. there was never cached data to serve, so useQuery always fetched on every navigation to the host details page.
After moving it out of AppWrapper, refetchOnMount: false works as expected and the cached (stale) data is served instead of refetching.
The fix removes the refetchOnMount: false, refetchOnReconnect: false, and refetchOnWindowFocus: false overrides, restoring react-query's defaults so data is refreshed on navigation, tab focus, and reconnect.
Checklist for submitter
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Screen.Recording.2026-02-26.at.1.19.56.PM.mov
For unreleased bug fixes in a release candidate, one of: