From 08626273c12abdcd42e5d1a156fb274e678e23fc Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 30 Sep 2026 02:07:56 -0700 Subject: [PATCH] fix(tests): keep the preview turn-budget test inside its timeout under CPU load The four-patch turn-budget test drove 2,400 deltas over a ~300 KB base, about 2.4 s of CPU on an idle machine and 11-15 s at load 150, past the 10 s test timeout. Pacing already runs on fake timers; the flake was CPU time, not wall clock. Four 30 s patches at a 500 ms tick still stream ~25 MB uncapped against the 8 MiB budget, so the test still fails when the cap is removed. --- .../mothership/request/go/file-preview-adapter.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/sim/lib/mothership/request/go/file-preview-adapter.test.ts b/apps/sim/lib/mothership/request/go/file-preview-adapter.test.ts index f83781dcee3..0c3038b8cdd 100644 --- a/apps/sim/lib/mothership/request/go/file-preview-adapter.test.ts +++ b/apps/sim/lib/mothership/request/go/file-preview-adapter.test.ts @@ -268,11 +268,17 @@ describe('processFilePreviewStreamEvent — preview byte rate', () => { expect(completed).toBe(true) }) + /** + * Each 30 s patch of the ~300 KB file would stream ~6 MB of snapshots on its own, + * so four of them exceed the turn budget several times over without its cap. The + * 500 ms tick keeps the delta count, and so the test's CPU time, small enough to + * stay far inside the test timeout on a loaded machine. + */ it('bounds all preview content in a turn of four long patches, and still completes each', async () => { const turn = newTurn() let contentBytes = 0 for (let edit = 0; edit < 4; edit++) { - const result = await streamPatch(120_000, 200, { turn, edit }) + const result = await streamPatch(30_000, 500, { turn, edit }) expect(result.completed).toBe(true) contentBytes += result.contentBytes }