fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Unexpected and intermittent reloads of the `policies` and `users` table/page

Open GrayW opened this issue 5 months ago β€’ 5 comments

Fleet versions 4.85.0 / 4.87.1 / dogfood: 4.89.0-rc

  • Discovered: 4.87.1
  • Reproduced: 4.85.0 / 4.87.1 / 4.89.0-rc.2606302019

Web browser and operating system: Google Chrome 149.x / Firefox 152.0.3 // macOS / Ubuntu GNOME


πŸ’₯ Β Actual behavior

On the /policies and /users page, the table appears to reload itself intermittently, and when selecting outside the browser window and returning. This causes issues when selecting multiple items.

πŸ› οΈ Expected behavior

The table should not randomly reload, forcing the user to re-select items, or be returned to the first page of results.

πŸ§‘β€πŸ’» Β Steps to reproduce

These steps:

  • [x] Have been confirmed to consistently lead to reproduction in multiple Fleet instances.
  1. Browse to /policies or /users
  2. Attempt to select multiple items
  3. Click outside the browser window, and then click back a few seconds later
  4. Can also happen during selection.

πŸ•―οΈ More info (optional)

  • Doesn't happen with /hosts or /reports
  • See Slack thread for extra screen recordings with the network developer tools visible for policies
  • See Slack thread for screen recordings for users

https://github.com/user-attachments/assets/dd28e7b4-305e-4a32-af12-b012666a7862

Image Image

GrayW avatar Jul 01 '26 10:07 GrayW

  • Updated this issue as the same behaviour is present on users

  • @rachaelshaw let me know if you'd prefer it to be separate

  • Discovered in 4.85.0. Added released bug label

GrayW avatar Jul 02 '26 14:07 GrayW

@GrayW Opened #48742 for this. It fixes the table losing focus on Policies and Users page

rrahul-1 avatar Jul 07 '26 20:07 rrahul-1

Hi @rrahul-1, thank you for the contribution. We'll get that reviewed as soon as we can.

GrayW avatar Jul 08 '26 08:07 GrayW

Validation: #48542 β€” Intermittent reloads of /policies and /users tables

Verdict: βœ… CONFIRMED FIXED β€” code review + live API checks + manual test plan all pass Instance: https://localhost:8080 β€” v4.90.0-rc.2607232113 (branch rc-minor-fleet-v4.90.0) Fix: PR #48742 (rrahul-1), commit 9f8caea025, merged 2026-07-13, on the RC branch

1. Code review βœ…

Root cause: production QueryClient (new QueryClient(), no defaults) β†’ queries inherit React Query's refetchOnWindowFocus: true. On window refocus the list refetched, tripping react-table's autoResetSelectedRows/autoResetPage β†’ selection lost / page reset.

Check Result
Fix on RC branch βœ… 9f8caea025 ancestor of HEAD
refetchOnWindowFocus:false on all policies useQuery calls βœ… 6 calls / 6 flagged
Same on users table βœ… 2 calls / 2 flagged (users + invites)
Changes file βœ… present

Finding (non-blocking): fix is tactical, not root-cause β€” router/index.tsx:128 is still new QueryClient() with no defaults; the DEFAULT_USE_QUERY_OPTIONS constant (refetchOnWindowFocus:false) is not applied globally. Other tables relying on the default stay latently exposed. Reasonable low-risk choice; worth a follow-up to set the QueryClient default.

2. Live API checks βœ… (Bearer auth, admin [email protected])

Endpoint Result
GET /api/latest/fleet/me 200 β€” admin
GET /api/latest/fleet/policies 200
GET /api/latest/fleet/policies/count 200
GET /api/latest/fleet/users 200 β€” 7 users

3. Manual test plan βœ… (headless Chrome via Playwright β€” cert-ignored, token injected as __Host-token cookie)

Repro: load page β†’ select rows β†’ blur/refocus window β†’ table must not reload/lose selection. Positive control on BOTH pages: a window focus/visibilitychange listener I registered fired (focus:1, vis:1) and its control fetch to /fleet/version appeared post-focus β€” proving the events reached window listeners (the exact mechanism React Query v3 uses).

Step Policies Users
Authenticated & table rendered βœ… βœ…
Focus events delivered (positive control) βœ… focus+vis, control fetch seen βœ… focus+vis, control fetch seen
Only non-list (/version control) fired post-focus βœ… βœ…
Row selection preserved after focus βœ… n/a (no row selection in table)

Interpretation: the focus events demonstrably fired (control fetch fired), yet the policies/users list queries did NOT refetch and the policies row selection survived β€” i.e. the queries correctly opted out via refetchOnWindowFocus:false. Pre-fix, the list would have refetched and cleared selection.

xpkoala avatar Jul 27 '26 16:07 xpkoala

Table reloads cease, Seamless, like a calm, glass sea. Fleet's path becomes peace.

fleet-release avatar Aug 06 '26 02:08 fleet-release