From 5f7177a0a983b0eb2733605026ee0d9bb4dcdb53 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Fri, 10 Jul 2026 00:55:47 +0800 Subject: [PATCH] Stabilize workflow worker coverage wait --- .../tests/workflow-workerthread.spec.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts b/packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts index ecaeed61f6..8d623e8a6f 100644 --- a/packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts +++ b/packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts @@ -17,6 +17,8 @@ function fakeParent(): Agent { /** The vm-context escape hatch, spelled once: real Worker tests use it to make the WORKER misbehave. */ const ESCAPE = "globalThis.constructor.constructor('return process')()" +/** Linux coverage workers can take longer than Vitest's default waitFor timeout to start executing script. */ +const WORKER_CHILD_START_TIMEOUT_MS = 3_000 /** One controllable child run: the test (or auto mode) settles it. */ interface ControlledRun { @@ -572,7 +574,7 @@ describe('dsh-workflow-workerthread', () => { `), parent: fakeParent(), }) - await vi.waitFor(() => { expect(starts).toBe(1) }) + await vi.waitFor(() => { expect(starts).toBe(1) }, { timeout: WORKER_CHILD_START_TIMEOUT_MS }) handle.cancel('stop now') await vi.waitFor(() => { expect(cancelled).toEqual(['stop now']) }, { timeout: 800 }) // The wedged worker's own completion loses to the in-flight cancel. @@ -602,7 +604,7 @@ describe('dsh-workflow-workerthread', () => { `), parent, }) - await vi.waitFor(() => { expect(provider.runs.length).toBe(1) }) + await vi.waitFor(() => { expect(provider.runs.length).toBe(1) }, { timeout: WORKER_CHILD_START_TIMEOUT_MS }) const before = Date.now() await handle.dispose() // Bounded by the grace (plus the terminate), never by the 1.5s spin.