Skip to content

Commit b63653f

Browse files
authored
fix: don't propagate nested aroundEach/All errors but aggregate them on runner (#9673)
1 parent 1d9e3b3 commit b63653f

File tree

2 files changed

+481
-20
lines changed

2 files changed

+481
-20
lines changed

packages/runner/src/run.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ async function callAroundHooks<THook extends Function>(
267267
return
268268
}
269269

270+
const hookErrors: unknown[] = []
271+
270272
const createTimeoutPromise = (
271273
timeout: number,
272274
phase: 'setup' | 'teardown',
@@ -352,23 +354,13 @@ async function callAroundHooks<THook extends Function>(
352354
setupTimeout.clear()
353355

354356
// Run inner hooks - don't time this against our teardown timeout
355-
let nextError: { value: unknown } | undefined
356-
try {
357-
await runNextHook(index + 1)
358-
}
359-
catch (value) {
360-
nextError = { value }
361-
}
357+
await runNextHook(index + 1).catch(e => hookErrors.push(e))
362358

363359
// Start teardown timer after inner hooks complete - only times this hook's teardown code
364360
teardownTimeout = createTimeoutPromise(timeout, 'teardown', stackTraceError)
365361

366362
// Signal that use() is returning (teardown phase starting)
367363
resolveUseReturned()
368-
369-
if (nextError) {
370-
throw nextError.value
371-
}
372364
}
373365

374366
// Start setup timeout
@@ -422,7 +414,11 @@ async function callAroundHooks<THook extends Function>(
422414
}
423415
}
424416

425-
await runNextHook(0)
417+
await runNextHook(0).catch(e => hookErrors.push(e))
418+
419+
if (hookErrors.length > 0) {
420+
throw hookErrors
421+
}
426422
}
427423

428424
async function callAroundAllHooks(

0 commit comments

Comments
 (0)