[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll - #289776
Merged
shahzad31 merged 2 commits intoSep 15, 2026
Merged
Conversation
shahzad31
marked this pull request as ready for review
September 15, 2026 08:35
pierrehilbert
approved these changes
Sep 15, 2026
shahzad31
enabled auto-merge (squash)
September 15, 2026 08:51
lucaslopezf
approved these changes
Sep 15, 2026
…ew scroll useFetchMaintenanceWindows had no staleTime, so react-query treated its cached result as stale immediately. The hook is called per monitor card (MetricItemIcon -> useMonitorMWs) from the virtualized overview grid, so scrolling — which constantly mounts fresh card instances — fired a brand new /internal/synthetics/monitors/maintenance_windows request for every card instead of reusing the one already-cached result. Set staleTime to match the existing refetchInterval (5 minutes), the window during which maintenance-window data is already known to be safe to reuse without polling.
shahzad31
force-pushed
the
shahzad/synthetics-mw-refetch-on-scroll
branch
from
September 15, 2026 09:18
8869702 to
34240c1
Compare
Contributor
💛 Build succeeded, but was flaky
Failed CI Steps
Metrics [docs]Page load bundle
Test Failures
History
|
Contributor
|
Starting backport for target branches: 8.19, 9.4, 9.5 |
This was referenced Sep 15, 2026
Contributor
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
kibanamachine
added a commit
that referenced
this pull request
Sep 15, 2026
…overview scroll (#289776) (#291103) # Backport This will backport the following commits from `main` to `9.4`: - [[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)](#289776) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-09-15T11:41:29Z","message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","author:actionable-obs","v9.6.0"],"title":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll","number":289776,"url":"https://github.com/elastic/kibana/pull/289776","mergeCommit":{"message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/289776","number":289776,"mergeCommit":{"message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com>
kibanamachine
added a commit
that referenced
this pull request
Sep 15, 2026
…overview scroll (#289776) (#291104) # Backport This will backport the following commits from `main` to `9.5`: - [[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)](#289776) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-09-15T11:41:29Z","message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","author:actionable-obs","v9.6.0"],"title":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll","number":289776,"url":"https://github.com/elastic/kibana/pull/289776","mergeCommit":{"message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/289776","number":289776,"mergeCommit":{"message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com>
kibanamachine
added a commit
that referenced
this pull request
Sep 15, 2026
… overview scroll (#289776) (#291101) # Backport This will backport the following commits from `main` to `8.19`: - [[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)](#289776) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-09-15T11:41:29Z","message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","author:actionable-obs","v9.6.0"],"title":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll","number":289776,"url":"https://github.com/elastic/kibana/pull/289776","mergeCommit":{"message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/289776","number":289776,"mergeCommit":{"message":"[Synthetics] Stop per-card maintenance-window refetch storm on overview scroll (#289776)\n\n## Summary\n\n`useFetchMaintenanceWindows` had no `staleTime`, so react-query treated\nits cached result as stale immediately after every fetch. The hook is\ncalled per monitor card (`MetricItemIcon` -> `useMonitorMWs`) from the\nvirtualized Synthetics overview grid, so scrolling — which constantly\nmounts fresh card instances as new rows come into view — fired a brand\nnew `GET /internal/synthetics/monitors/maintenance_windows` request for\nevery card, instead of reusing the one already-cached result.\n\n## Fix\n\nSet `staleTime` to match the hook's existing `refetchInterval` (5\nminutes) — the same window during which the data is already known to be\nsafe to reuse (maintenance windows only take effect on a sync interval,\nand the existing `refetchInterval` comment explains why 5 minutes is the\nright cadence). This is a one-line change with no behavior change to the\nperiodic background polling.\n\n## Testing\n\n- Added a unit test (`use_fetch_maintenance_windows.test.ts`) asserting\n`staleTime` matches `refetchInterval`; confirmed red (fails without the\nfix) / green (passes with it).\n- Verified live: on the Synthetics overview page (card view), scrolling\nto load new pages of monitors previously fired one `maintenance_windows`\nrequest per newly-mounted card. After the fix, scrolling through\nnewly-loaded pages triggers zero additional requests.\n\n## Test plan\n\n- [x] Unit test added and passing\n- [x] Verified locally in a real browser (network trace before/after)\n- [x] `node scripts/eslint --fix` clean\n- [x] Scoped type-check clean (`synthetics` project full pass)","sha":"e443f816d1018d365c92bd7a6138be218bde19a9"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com>
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.
Summary
useFetchMaintenanceWindowshad nostaleTime, 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 newGET /internal/synthetics/monitors/maintenance_windowsrequest for every card, instead of reusing the one already-cached result.Fix
Set
staleTimeto match the hook's existingrefetchInterval(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 existingrefetchIntervalcomment explains why 5 minutes is the right cadence). This is a one-line change with no behavior change to the periodic background polling.Testing
use_fetch_maintenance_windows.test.ts) assertingstaleTimematchesrefetchInterval; confirmed red (fails without the fix) / green (passes with it).maintenance_windowsrequest per newly-mounted card. After the fix, scrolling through newly-loaded pages triggers zero additional requests.Test plan
node scripts/eslint --fixcleansyntheticsproject full pass)