From 03c098d24838e2c7f8a72f776921cc7747aaa022 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 13 Apr 2026 17:20:02 +0000 Subject: [PATCH] Add dispose method to PerfAppHarness for lightweight error-path cleanup PerfAppHarness only exposed finishRun which bundles teardown with artifact writing. If finishRun threw after teardown, the original test error was masked. Tests were also forced to repeat full artifact parameters in finally blocks. Add a standalone dispose() method (matching ServerPerfHarness API) that tears down browser/server/temp files without writing artifacts. Simplify test finally blocks to use dispose() instead of redundant finishRun calls. --- apps/web/test/perf/appHarness.ts | 5 +++++ .../web/test/perf/virtualization.perf.test.ts | 14 +------------- .../perf/websocket-application.perf.test.ts | 19 +------------------ 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/apps/web/test/perf/appHarness.ts b/apps/web/test/perf/appHarness.ts index 3f96d7ffdd..1faba0a07e 100644 --- a/apps/web/test/perf/appHarness.ts +++ b/apps/web/test/perf/appHarness.ts @@ -102,6 +102,7 @@ export interface PerfAppHarness { readonly browserMetrics: BrowserPerfMetrics; readonly serverMetrics: ReadonlyArray | null; }>; + readonly dispose: () => Promise; } async function pickFreePort(): Promise { @@ -467,6 +468,10 @@ export async function startPerfAppHarness( return await finishPromise; }, + dispose: async () => { + await sampler.stop().catch(() => undefined); + await teardown(); + }, }; } catch (error) { await Promise.allSettled([ diff --git a/apps/web/test/perf/virtualization.perf.test.ts b/apps/web/test/perf/virtualization.perf.test.ts index 34b3e8fd88..07f4dc41bf 100644 --- a/apps/web/test/perf/virtualization.perf.test.ts +++ b/apps/web/test/perf/virtualization.perf.test.ts @@ -163,19 +163,7 @@ test("virtualization stays bounded and heavy thread switches remain snappy", asy finished = true; } finally { if (harness && !finished) { - await harness.finishRun({ - suite: "virtualization", - scenarioId: "large_threads", - thresholds, - metadata: { - heavyThreadMessageCount: harness.seededState.threadSummaries.find( - (thread) => thread.id === PERF_CATALOG_IDS.largeThreads.heavyAThreadId, - )?.messageCount, - }, - actionSummary: { - threadSwitchActionPrefix: "thread-switch", - }, - }); + await harness.dispose(); } } }); diff --git a/apps/web/test/perf/websocket-application.perf.test.ts b/apps/web/test/perf/websocket-application.perf.test.ts index 29b53fa0df..0387501887 100644 --- a/apps/web/test/perf/websocket-application.perf.test.ts +++ b/apps/web/test/perf/websocket-application.perf.test.ts @@ -117,24 +117,7 @@ test("high-frequency websocket events stay responsive under real built-app flow" finished = true; } finally { if (harness && !finished) { - await harness.finishRun({ - suite: "websocket-application", - scenarioId: "dense_assistant_stream", - thresholds, - metadata: { - burstSeedThreadId: PERF_CATALOG_IDS.burstBase.burstThreadId, - navigationThreadId: PERF_CATALOG_IDS.burstBase.navigationThreadId, - fillerThreadId: PERF_CATALOG_IDS.burstBase.fillerThreadId, - navigationLiveAssistantMessageId: - PERF_CATALOG_IDS.provider.navigationLiveAssistantMessageId, - burstLiveAssistantMessageId: PERF_CATALOG_IDS.provider.burstLiveAssistantMessageId, - sentinelText: PERF_PROVIDER_SCENARIOS.dense_assistant_stream.sentinelText, - }, - actionSummary: { - threadSwitchActionPrefix: "thread-switch", - burstActionName: "burst-completion", - }, - }); + await harness.dispose(); } } });