vitest-dev / vitest-dev/vitest

Error with server.deps.inline and coverage

Open
#7,950 6 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p3-minor-bug
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

Config:

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    environment: 'jsdom',
    server: {
      deps: {
        inline: true,
      },
    },
    coverage: {
      provider: 'v8',
      enabled: true,
    },
  }
});

Log:

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: Session is not connected
 ❯ Session.post node:inspector:126:13
 ❯ node_modules/.pnpm/@vitest+coverage-v8@3.1.3_vitest@3.1.3_jsdom@26.1.0_/node_modules/@vitest/coverage-v8/dist/index.js:23:12
     21|  takeCoverage(options) {
     22|   return new Promise((resolve, reject) => {
     23|    session.post("Profiler.takePreciseCoverage", async (error, coverage) => {
       |            ^
     24|     if (error) {
     25|      return reject(error);
 ❯ Object.takeCoverage node_modules/.pnpm/@vitest+coverage-v8@3.1.3_vitest@3.1.3_jsdom@26.1.0_/node_modules/@vitest/coverage-v8/dist/index.js:22:10
 ❯ takeCoverageInsideWorker node_modules/.pnpm/vitest@3.1.3_jsdom@26.1.0/node_modules/vitest/dist/chunks/setup-common.AQcDs321.js:16:39
 ❯ processTicksAndRejections node:internal/process/task_queues:105:5
 ❯ VitestTestRunner.testRunner.onAfterRunFiles node_modules/.pnpm/vitest@3.1.3_jsdom@26.1.0/node_modules/vitest/dist/chunks/index.Cu2UlluP.js:78:20
 ❯ startTests node_modules/.pnpm/@vitest+runner@3.1.3/node_modules/@vitest/runner/dist/index.js:1572:2
 ❯ node_modules/.pnpm/vitest@3.1.3_jsdom@26.1.0/node_modules/vitest/dist/chunks/runBaseTests.BV8m0B-u.js:122:5
 ❯ withEnv node_modules/.pnpm/vitest@3.1.3_jsdom@26.1.0/node_modules/vitest/dist/chunks/runBaseTests.BV8m0B-u.js:88:3

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_INSPECTOR_NOT_CONNECTED' }
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯


 Test Files   (1)
      Tests   (1)
     Errors  1 error
   Start at  12:59:36
   Duration  666ms (transform 1.26s, setup 0ms, collect 8ms, tests 0ms, environment 428ms, prepare 65ms)
Reproduction

https://github.com/Jinjiang/reproductions/tree/vitest-deps-inline-20250509

System Info
System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M1
    Memory: 156.19 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.local/share/mise/installs/node/22/bin/node
    Yarn: 1.22.18 - ~/.yarn/bin/yarn
    npm: 10.9.2 - ~/.local/share/mise/installs/node/22/bin/npm
    pnpm: 9.10.0 - ~/Library/pnpm/pnpm
    bun: 1.1.36 - ~/.local/share/mise/installs/bun/latest/bin/bun
  Browsers:
    Safari: 18.5
  npmPackages:
    @vitest/coverage-v8: ^3.1.3 => 3.1.3 
    vitest: ^3.0.9 => 3.1.3
Used Package Manager

pnpm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction and trace takeCoverageInsideWorker and onAfterRunFiles, where @vitest/coverage-v8 calls Session.post for Profiler.takePreciseCoverage. Compare the server.deps.inline and coverage configuration, then verify the reproduction completes without an ERR_INSPECTOR_NOT_CONNECTED unhandled error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.