[9.4] [Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776) - #291103
Merged
Conversation
…ew scroll (elastic#289776) ## Summary `useFetchMaintenanceWindows` had no `staleTime`, so react-query treated its cached result as stale immediately after every fetch. The hook is called per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the virtualized Synthetics overview grid, so scrolling — which constantly mounts fresh card instances as new rows come into view — fired a brand new `GET /internal/synthetics/monitors/maintenance_windows` request for every card, instead of reusing the one already-cached result. ## Fix Set `staleTime` to match the hook's existing `refetchInterval` (5 minutes) — the same window during which the data is already known to be safe to reuse (maintenance windows only take effect on a sync interval, and the existing `refetchInterval` comment explains why 5 minutes is the right cadence). This is a one-line change with no behavior change to the periodic background polling. ## Testing - Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting `staleTime` matches `refetchInterval`; confirmed red (fails without the fix) / green (passes with it). - Verified live: on the Synthetics overview page (card view), scrolling to load new pages of monitors previously fired one `maintenance_windows` request per newly-mounted card. After the fix, scrolling through newly-loaded pages triggers zero additional requests. ## Test plan - [x] Unit test added and passing - [x] Verified locally in a real browser (network trace before/after) - [x] `node scripts/eslint --fix` clean - [x] Scoped type-check clean (`synthetics` project full pass) (cherry picked from commit e443f81)
4 tasks
Contributor
Author
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
Test Failures
cc @shahzad31 |
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.
Backport
This will backport the following commits from
mainto9.4:Questions ?
Please refer to the Backport tool documentation