fix(desktop): coalesce the update checks fired by window focus and visibility - #10250
GuidoMaxier wants to merge 1 commit into
Conversation
Returning to the app window fired a fresh CheckUpdate on every focus and visibilitychange, and each call holds the bridge for 1.4-3.5 s (28.5 s in one breadcrumb window from esengine#10186). Toggling between windows therefore queued one multi-second call per toggle. Throttle only the window-event path to 5 minutes; the hourly interval keeps its own schedule. The existing test pinned the old one-refresh-per-event behaviour, so it now asserts coalescing, window expiry and listener cleanup. Fixes esengine#10192
|
CI evidence. This is a fork pull request, so the checks of this PR stay in The only red job is That job is not related to this diff. An unrelated branch ( Local gates on this revision: |
subscribeToUpdateRefreshindesktop/frontend/src/components/UpdateBanner.tsxsubscribedfocusandvisibilitychangeto a barerefresh(), so every toggle of the app window started a newCheckUpdate.That check holds the bridge for seconds — 1.4–3.5 s in #10192's own measurements, 28.5 s in one of the breadcrumb windows reported on #10186 — so switching between windows queued one multi-second call per toggle.
useUpdateronly guards against superseding a check that is in flight (isBusyOperation); once a check finishes, the next window event starts another.Change
Throttle the window-event path to 5 minutes. The hourly interval keeps its own schedule, so the periodic check is unaffected.
UPDATE_REFRESH_MIN_EVENT_INTERVAL_MS = 5 * 60 * 1000, exposed as an optional third parameter so callers and tests can tune it.visibilitychangefor a hidden window is still ignored, as before.CheckUpdateitself behaves exactly as it did.Test
desktop/frontend/src/__tests__/updater-shared-state.test.tsxalready pinned the old behaviour:Two events produced two refreshes — the defect written down as an expectation. It now asserts coalescing inside the throttle window, a new refresh once that window elapses, and that cleanup still removes both listeners.
Verification
pnpm exec tsx src/__tests__/updater-shared-state.test.tsx→ 54 passed, 0 failedpnpm typecheck→ 0 errorspnpm test:typecheck→ 0 errorspnpm lint:hooks→ cleanRefs #10192
Documentation-impact: none - the change is a client-side event throttle in
UpdateBanner.tsx; the user-facing updater documentation describes when checks happen (at launch and periodically), and none of it documents a per-window-event refresh, so the existing docs remain correct.