{"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":231,"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":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/pool.ts#L213-L249","documentation":"AggregateError wrapping every rejected task promise from a single executeTests run. After all task groups (and browser specs) settle via Promise.allSettled, any rejected results are collected and re-thrown together so the caller sees one error carrying all underlying failures (accessible via error.errors). The message is a generic wrapper; the real diagnostics live on the contained errors and the serialized state reported to the UI/reporters.","triggerScenarios":"One or more workers/browser tabs reject during pool.runTests or pool.collectTests in createPool (packages/vitest/src/node/pool.ts:221-235). Rejections include worker crashes, test-file load failures, environment setup errors inside a worker, or browser connection failures.","commonSituations":"A test file throws an uncaught exception during import/evaluation; a worker process exits unexpectedly (OOM, segfault); the browser pool fails to connect; a setup file errors. Anything that rejects a single task promise will surface here.","solutions":["Inspect the AggregateError.errors array (or the serialized error in the reporter output) to find the root cause of each rejection.","Fix the underlying test/setup/import error reported in the first contained error.","Run a single failing file in isolation (vitest run path/to/file.test.ts) to reproduce without aggregation noise.","Check vitest.state.getUnhandledErrors() / reporter 'unhandled error' output for worker-side context."],"exampleFix":"// before: only see the aggregate message\ntry {\n  await pool.runTests(files)\n}\ncatch (e) {\n  console.error(e.message) // 'Errors occurred while running tests...'\n}\n\n// after: surface each underlying error\ntry {\n  await pool.runTests(files)\n}\ncatch (e) {\n  if (e instanceof AggregateError) {\n    for (const cause of e.errors) console.error(cause)\n  } else {\n    throw e\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// AggregateError-aware catch: surface each underlying cause\ntry {\n  await vitest.start()\n} catch (e) {\n  const causes = e instanceof AggregateError ? e.errors : [e]\n  for (const cause of causes) console.error(cause)\n  process.exitCode = 1\n}","preventionTips":["Treat each AggregateError.errors entry as the real failure to fix, not the wrapper message.","Run the single failing file in isolation to drop aggregation noise.","Wire reporters (junit/html) to capture per-file failures for triage."],"tags":["aggregate","worker","test-runner"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}