{"record":{"id":"0d06eccff3ec5243","repo":"vitest-dev/vitest","slug":"errors-occurred-while-running-tests-for-more-info","errorCode":null,"errorMessage":"Errors occurred while running tests. For more information, see serialized error.","messagePattern":"Errors occurred while running tests\\. For more information, see serialized error\\.","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/pool.ts","lineNumber":222,"sourceCode":"        if (method === 'collect') {\n          promises.push(browserPool.collectTests(browserSpecs))\n        }\n        else {\n          promises.push(browserPool.runTests(browserSpecs))\n        }\n      }\n\n      const groupResults = await Promise.allSettled(promises)\n\n      results.push(...groupResults)\n    }\n\n    const errors = results\n      .filter(result => result.status === 'rejected')\n      .map(result => result.reason)\n\n    if (errors.length > 0) {\n      throw new AggregateError(\n        errors,\n        'Errors occurred while running tests. For more information, see serialized error.',\n      )\n    }\n  }\n\n  return {\n    name: 'default',\n    runTests: (files, invalidates) => executeTests('run', files, invalidates),\n    collectTests: (files, invalidates) => executeTests('collect', files, invalidates),\n    async close() {\n      await Promise.all([\n        pool.close(),\n        browserPool?.close?.(),\n        ...ctx.projects.map(project => project.typechecker?.stop()),\n      ])\n    },\n  }","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/pool.ts#L204-L240","documentation":"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.","triggerScenarios":"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.","commonSituations":"Worker process crash; environment initialization failure; pool resource exhaustion; custom pool implementation bug; out-of-memory in a worker.","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."],"exampleFix":"// before - opaque aggregate\ntry { await vitest.runFiles(specs) } catch (e) { console.error(e.message) }\n\n// after\ntry {\n  await vitest.runFiles(specs)\n} catch (e) {\n  const causes = (e.errors ?? []).map(c => c.stack || c).join('\\n')\n  console.error('Pool failures:\\n', causes)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isAggregateError(e): e is AggregateError {\n  return e instanceof Error && Array.isArray((e as any).errors)\n}","tryCatchPattern":"try {\n  await pool.runTests(specs)\n} catch (e) {\n  if (isAggregateError(e)) {\n    for (const cause of e.errors) console.error(cause)\n  } else throw e\n}","preventionTips":["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."],"tags":["pool","worker","aggregate-error"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}