Skip to content

[9.5] [Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776) - #291104

Merged
kibanamachine merged 1 commit into
elastic:9.5from
kibanamachine:backport/9.5/pr-289776
Sep 15, 2026
Merged

kibanamachine merged 1 commit into
elastic:9.5from
kibanamachine:backport/9.5/pr-289776

Conversation

@kibanamachine

Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.5:

Questions ?

Please refer to the Backport tool documentation

…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)
@kibanamachine kibanamachine added the reviewer:libra PR review with Libra. This disables Claude and Scout reviewers label Sep 15, 2026
@kibanamachine

Copy link
Copy Markdown
Contributor Author

Selected for Libra review

This PR was selected for Libra review as part of the temporary 50% trial.

To opt out permanently, remove the reviewer:libra label. It will not be added again to this PR.

@kibanamachine

Copy link
Copy Markdown
Contributor Author

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
synthetics 1.3MB 1.3MB +16.0B

Test Failures

  • [job] [logs] FTR Configs #35 / Fleet tasks Agent status change task "after all" hook for "should handle agents with no local_metadata without throwing"

cc @shahzad31

@kibanamachine
kibanamachine merged commit bbf23df into elastic:9.5 Sep 15, 2026
90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR reviewer:libra PR review with Libra. This disables Claude and Scout reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants