Skip to content

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Vitest v4 Fork Runner Timeout Bug Reproduction

This monorepo is designed to reproduce the timeout issue with Vitest v4's fork runner as described in issue #8968.

The Bug

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.

Project Structure

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

Test Distribution

  • 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.

Quick Start

Installation

yarn install

Run Tests

# 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

View Test Statistics

./show-test-distribution.sh

Reproducing the Bug

The timeout error is most likely to occur when:

  1. Running tests in parallel across multiple workspaces:

    yarn turbo test
  2. Running with coverage enabled:

    yarn turbo test -- --coverage
  3. Running multiple times (the bug can be intermittent):

    for i in {1..5}; do echo "Run $i"; yarn turbo test; done

Configuration

Each workspace uses Vitest with:

  • bail: 3 - Stop after 3 test failures
  • logHeapUsage: true - Monitor memory usage
  • environment: '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.

Environment

  • 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)

Documentation

Related Issue

This reproduction case is for: vitest-dev/vitest#8968

Expected vs Actual Behavior

Expected (Vitest v3)

All tests run successfully with proper fork management and worker thread initialization.

Actual (Vitest v4)

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.

Contributing

If you can reproduce this issue or have insights into the root cause, please comment on the GitHub issue.

License

MIT

Releases

Packages

Contributors

Languages