Skip to content

React query caching fixes cherry pick - #40615

Merged
nulmete merged 2 commits into
rc-minor-fleet-v4.82.0from
nulmete/react-query-caching-fixes-cherry-pick
Feb 26, 2026
Merged

React query caching fixes cherry pick#40615
nulmete merged 2 commits into
rc-minor-fleet-v4.82.0from
nulmete/react-query-caching-fixes-cherry-pick

Conversation

@nulmete

@nulmete nulmete commented Feb 26, 2026

Copy link
Copy Markdown
Member

Cherry-picking fixes for #40608 and #40603 (already merged to main)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #40606 

# Checklist for submitter

- [x] 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/ab873ea4-2baa-4218-b16c-c75f16bbda34



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
)

<!-- 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
nulmete requested a review from a team as a code owner February 26, 2026 17:19
@nulmete nulmete changed the title Nulmete/react query caching fixes cherry pick React query caching fixes cherry pick Feb 26, 2026
@codecov

codecov Bot commented Feb 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (rc-minor-fleet-v4.82.0@b67ac38). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                    @@
##             rc-minor-fleet-v4.82.0   #40615   +/-   ##
=========================================================
  Coverage                          ?   66.34%           
=========================================================
  Files                             ?     2453           
  Lines                             ?   196260           
  Branches                          ?     8730           
=========================================================
  Hits                              ?   130209           
  Misses                            ?    54255           
  Partials                          ?    11796           
Flag Coverage Δ
frontend 54.14% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nulmete
nulmete merged commit eedc66a into rc-minor-fleet-v4.82.0 Feb 26, 2026
14 checks passed
@nulmete
nulmete deleted the nulmete/react-query-caching-fixes-cherry-pick branch February 26, 2026 17:27
@georgekarrv georgekarrv mentioned this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants