vitest-dev/vitest · error · AggregateError
Errors occurred while running tests. For more information…
Error message
Errors occurred while running tests. For more information, see serialized error.
What it means
AggregateError thrown by executeTests when one or more worker-group runs reject. It collects every rejected reason from the Promise.allSettled results and wraps them with a generic message; the real causes live on error.errors. Indicates a pool/worker-level failure rather than an individual test failure.
Solutions
- Inspect error.errors[] for the underlying causes (the top message is intentionally generic).
- Run with a single worker / pool=forks to surface errors directly.
- Increase worker memory/limits and check environment setup logs.
- If using a custom pool, debug its createPoolWorker/runTests path.
Example fix
// before - opaque aggregate
try { await vitest.runFiles(specs) } catch (e) { console.error(e.message) }
// after
try {
await vitest.runFiles(specs)
} catch (e) {
const causes = (e.errors ?? []).map(c => c.stack || c).join('\n')
console.error('Pool failures:\n', causes)
} Defensive patterns
Strategy: try-catch
Type guard
function isAggregateError(e): e is AggregateError {
return e instanceof Error && Array.isArray((e as any).errors)
} Try / catch
try {
await pool.runTests(specs)
} catch (e) {
if (isAggregateError(e)) {
for (const cause of e.errors) console.error(cause)
} else throw e
} Prevention
- Always read error.errors[]; the top-level message is intentionally generic.
- Reproduce with a single worker to surface the underlying cause directly.
- Monitor worker memory and environment-init failures in CI.
When it happens
Trigger: Any worker pool group (threads/forks/vmThreads/vmForks/browser/typescript or a custom pool) rejecting during runTests/collectTests — worker spawn failure, environment init crash, pool resource exhaustion, or a bug in a custom pool.
Common situations: Worker process crash; environment initialization failure; pool resource exhaustion; custom pool implementation bug; out-of-memory in a worker.
Related errors
- Cannot resolve user fixtures. See errors for more…
- Environment " " is not a valid environment. Path " "…
- Failed to initialize projects. There were errors during…
- Failed to load custom "defines
- Pool " " cannot run with "experimental.viteModuleRunner…
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/0d06eccff3ec5243.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vitest/src/node/pool.ts:222
if (method === 'collect') {
promises.push(browserPool.collectTests(browserSpecs))
}
else {
promises.push(browserPool.runTests(browserSpecs))
}
}
const groupResults = await Promise.allSettled(promises)
results.push(...groupResults)
}
const errors = results
.filter(result => result.status === 'rejected')
.map(result => result.reason)
if (errors.length > 0) {
throw new AggregateError(
errors,
'Errors occurred while running tests. For more information, see serialized error.',
)
}
}
return {
name: 'default',
runTests: (files, invalidates) => executeTests('run', files, invalidates),
collectTests: (files, invalidates) => executeTests('collect', files, invalidates),
async close() {
await Promise.all([
pool.close(),
browserPool?.close?.(),
...ctx.projects.map(project => project.typechecker?.stop()),
])
},
}View on GitHub (pinned to 1fa9837ec2)