From 083e9489d9943beaf624e77821beb09a8c41da5f Mon Sep 17 00:00:00 2001 From: Max Lampert Date: Mon, 24 Aug 2026 21:34:01 -0700 Subject: [PATCH] fix(desktop): discard stale longtask deliveries at perf-sample start Blind-review round 5 (Fable medium) finding: a longtask trailing switch N is delivered by the PerformanceObserver in a later task and landed in switch N+1's freshly reset array, inflating its longtask lines. Drain takeRecords() and discard before each sample's reset. Co-Authored-By: Claude Fable 5 Signed-off-by: Max Lampert --- desktop/tests/e2e/member-heavy-switch.perf.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desktop/tests/e2e/member-heavy-switch.perf.ts b/desktop/tests/e2e/member-heavy-switch.perf.ts index 69efb094ab..1fdff110af 100644 --- a/desktop/tests/e2e/member-heavy-switch.perf.ts +++ b/desktop/tests/e2e/member-heavy-switch.perf.ts @@ -94,6 +94,10 @@ async function measureSwitch( __LONGTASKS__: number[]; __LONGTASK_OBSERVER__?: PerformanceObserver; }; + // Discard pending deliveries from BEFORE this sample: a longtask + // trailing the previous switch is delivered in a later task and would + // otherwise land in this sample's fresh array. + store.__LONGTASK_OBSERVER__?.takeRecords(); store.__LONGTASKS__ = []; const link = document.querySelector( `[data-testid="${args.targetTestId}"]`,