Skip to content

Commit f2c5d92

Browse files
committed
test(workers): reject on worker timeout in CI too; terminate to avoid pending tests and surface clear failure
1 parent 7b3741c commit f2c5d92

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/workers/cache-grouped-scripts-worker.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,11 @@ function runWorkerMessage(messageToSend: any): Promise<{ msg: any; worker: Worke
6969
// Add timeout to prevent hanging
7070
setTimeout(() => {
7171
if (!resolved) {
72-
if (process.env.CI) {
73-
console.error('[worker-diag] timeout waiting for CACHE_MAIN_SCRIPTS; terminating worker to avoid dangling thread')
74-
try { worker.terminate() } catch {}
75-
console.log('Timeout waiting for CACHE_MAIN_SCRIPTS message. This is expected to sometimes fail in CI, but need to investigate why...')
76-
} else {
77-
reject(new Error('Timeout waiting for CACHE_MAIN_SCRIPTS message'))
78-
}
72+
// Always fail fast with a clear error and terminate the worker.
73+
// Avoid leaving a pending Promise which causes AVA to time out.
74+
console.error('[worker-diag] timeout waiting for CACHE_MAIN_SCRIPTS; terminating worker to avoid dangling thread')
75+
try { worker.terminate() } catch {}
76+
reject(new Error('Timeout waiting for CACHE_MAIN_SCRIPTS message'))
7977
}
8078
}, 5000)
8179
})

0 commit comments

Comments
 (0)