Stabilize workflow worker coverage wait
This commit is contained in:
@@ -17,6 +17,8 @@ function fakeParent(): Agent {
|
|||||||
|
|
||||||
/** The vm-context escape hatch, spelled once: real Worker tests use it to make the WORKER misbehave. */
|
/** The vm-context escape hatch, spelled once: real Worker tests use it to make the WORKER misbehave. */
|
||||||
const ESCAPE = "globalThis.constructor.constructor('return process')()"
|
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. */
|
/** One controllable child run: the test (or auto mode) settles it. */
|
||||||
interface ControlledRun {
|
interface ControlledRun {
|
||||||
@@ -572,7 +574,7 @@ describe('dsh-workflow-workerthread', () => {
|
|||||||
`),
|
`),
|
||||||
parent: fakeParent(),
|
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')
|
handle.cancel('stop now')
|
||||||
await vi.waitFor(() => { expect(cancelled).toEqual(['stop now']) }, { timeout: 800 })
|
await vi.waitFor(() => { expect(cancelled).toEqual(['stop now']) }, { timeout: 800 })
|
||||||
// The wedged worker's own completion loses to the in-flight cancel.
|
// The wedged worker's own completion loses to the in-flight cancel.
|
||||||
@@ -602,7 +604,7 @@ describe('dsh-workflow-workerthread', () => {
|
|||||||
`),
|
`),
|
||||||
parent,
|
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()
|
const before = Date.now()
|
||||||
await handle.dispose()
|
await handle.dispose()
|
||||||
// Bounded by the grace (plus the terminate), never by the 1.5s spin.
|
// Bounded by the grace (plus the terminate), never by the 1.5s spin.
|
||||||
|
|||||||
Reference in New Issue
Block a user