Skip to content

vitest browser mode hangs when coverage-v8 or istanbul is installed, even when coverage is disabled #1525

@RobbyRabbitman

Description

@RobbyRabbitman

Describe the bug

I would like to report some weird observation and maybe some1 can look on that: vitest browser mode hangs when coverage-v8 or istanbul is installed, even when coverage is disabled.

I generated my workspace with the vp cli and it created some pnpm overrides, but Im unsure how that effects additional packages of the vitest eco system. vite-plus@0.1.20 has "@vitest/coverage-v8": 4.1.5 as an optional peer, so i guess its fine installing it. I also tried to understand this reexporting here https://github.com/voidzero-dev/vite-plus/blob/main/packages/test/BUNDLING.md. Idk if the issue is related to that or if its a vitest issue - I did not find anything in their repo. Maybe this issue vitest-dev/vitest#10252 but its not using browser mode.

packages:
  - e2e/*
  - packages/*
  - tools/*
catalog:
  "@types/lodash-es": 4.17.12
  "@types/node": 25.6.0
  '@vitest/coverage-istanbul': 4.1.5
  "@vitest/coverage-v8": 4.1.5
  lodash-es: 4.18.1
  playwright: 1.59.1
  typedoc: 0.28.19
  typedoc-plugin-markdown: 4.11.0
  typescript: 5.9.3
  vite: npm:@voidzero-dev/vite-plus-core@0.1.20
  vite-plus: 0.1.20
  vitest: npm:@voidzero-dev/vite-plus-test@0.1.20
  why-is-node-running: 3.2.2
catalogMode: strict
cleanupUnusedCatalogs: true
engineStrict: true
overrides:
  typedoc: "catalog:"
  typescript: "catalog:"
  vite: "catalog:"
  vitest: "catalog:"
peerDependencyRules:
  allowAny:
    - vite
    - vitest
  allowedVersions:
    vite: "*"
    vitest: "*"
saveExact: true

Summary

In browser mode, Vitest fails before test collection with:

  • [vitest] Browser connection was closed while running tests. Was the page closed unexpectedly?
  • [birpc] rpc is closed, cannot call "createTesters"

The run ends with no tests executed.

Repro commands

# Browser mode, no coverage
vp test run src/index.spec.ts --coverage.enabled false --reporter=verbose

# Browser mode, headed
vp test run src/index.spec.ts --coverage.enabled false --browser.headless false --reporter=verbose

# Browser mode, no isolation
vp test run src/index.spec.ts --coverage.enabled false --isolate=false --reporter=verbose

Actual Behavior

All browser-mode commands above fail with:

Error: Failed to run the test .../e2e/web-lib/src/index.spec.ts
Caused by: Error: [vitest] Browser connection was closed while running tests. Was the page closed unexpectedly?
Caused by: Error: [birpc] rpc is closed, cannot call "createTesters"

Vitest summary shows:

  • Tests no tests
  • Errors 1 error

Expected Behavior

Browser mode should connect, collect tests, and execute them.

Additional Findings

  1. Disabling coverage does not fix it

    • --coverage.enabled false still reproduces the same browser/RPC error.
  2. *Coverage package installation

    • Installing or not installing @vitest/coverage-istanbul and @vitest/coverage-v8 does have an effect - the error even happens with coverage disabled, the packages must not be installed actually so that tests run.
  3. Not a stale-port artifact

    • Killing stale listeners before rerun still reproduces the same error.
  4. --isolate=false does not fix it

    • Same browser connection/RPC-close error still occurs.
  5. Non-browser mode does not hit this failure path

    • Node/non-browser test runs in the workspace complete normally.
    • This appears specific to browser mode.

Diagnostics run

  • DEBUG=pw:browser,pw:api and DEBUG=vite:*,pw:api,pw:browser were used.
  • Logs show browser launch/context/page creation and Vitest test page navigation succeed.
  • Failure occurs before test collection starts (0 tests collected).

Environment (sanitized)

  • OS: macOS
  • Node.js: 24.x
  • Vitest runtime via bundled package from vite-plus toolchain
  • Browser provider: Playwright (Chromium)

Reproduction

x

Steps to reproduce

No response

System Info

0.1.20

Used Package Manager

pnpm

Logs

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Priority

    None yet

    Effort

    None yet

    Target date

    None yet

    Start date

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions