This monorepo is designed to reproduce the timeout issue with Vitest v4's fork runner as described in issue #8968.
After upgrading to Vitest 4, tests fail randomly with:
Error: [vitest-pool]: Timeout starting forks runner.
This occurs in monorepos with multiple packages when running tests in parallel via Turborepo or similar tools.
This is a Yarn 4 monorepo with:
- 11 applications in
apps/directory - 10 packages in
packages/directory - 299 test files distributed across all workspaces
- Turborepo for orchestrating parallel test execution
- Apps (136 test files): React component tests including Button, Card, Input, Form, List, Pagination, Modal, Table, Tabs, Dropdown, Badge, and custom hooks
- Packages (163 test files): Utility tests including math operations, string helpers, validators, async operations, HTTP clients, storage, events, regex, path operations, and color utilities
Run ./show-test-distribution.sh to see the detailed breakdown.
yarn install# Run all tests with Turbo (most likely to reproduce the bug)
yarn turbo test
# Run all tests with regular yarn
yarn test
# Run tests in a specific workspace
yarn workspace @threads/app-one test
yarn workspace @threads/package-one test./show-test-distribution.shThe timeout error is most likely to occur when:
-
Running tests in parallel across multiple workspaces:
yarn turbo test -
Running with coverage enabled:
yarn turbo test -- --coverage -
Running multiple times (the bug can be intermittent):
for i in {1..5}; do echo "Run $i"; yarn turbo test; done
Each workspace uses Vitest with:
bail: 3- Stop after 3 test failureslogHeapUsage: true- Monitor memory usageenvironment: 'happy-dom'- For React component testing- Coverage provider:
v8 - Test files:
**/*.test.*
See individual vite.config.ts or vite.config.js files in each workspace.
- Node.js: v22.21.0
- Yarn: 4.10.3
- Package Manager: Yarn 4 with PnP
- Vitest: v4.x (problematic) vs v3.x (working)
- Turbo: Latest version
- OS: macOS (also reproduces in CI environments)
- TEST_FILES_SUMMARY.md - Detailed breakdown of all test files
- TESTING.md - Complete testing guide with troubleshooting tips
This reproduction case is for: vitest-dev/vitest#8968
All tests run successfully with proper fork management and worker thread initialization.
Random timeouts occur when the fork pool manager fails to start worker threads within the timeout period, causing:
Error: [vitest-pool]: Timeout starting forks runner.
If you can reproduce this issue or have insights into the root cause, please comment on the GitHub issue.
MIT