Skip to content

EnvironmentTeardownError when mounting component with dynamic imports #9872

Description

@yvangrdv

Describe the bug

Since migrating to Vitest 4, I've been experiencing test errors that worked fine with Vitest 3.

In version 4.0, I was getting the error "Error: [vitest-worker]: Closing rpc while "fetch" was pending," and since version 4.1, I'm getting the error "EnvironmentTeardownError: Cannot load ..."

Unable to pinpoint the problem with my tests, I created a small project from scratch where I'm reproducing the issue with a minimal dynamic import scenario.

Here is the repo link

NOTE: I replaced the initial tsconfig with the contents of tsconfig.vitest.json. I don't know why, but if I don't do that, I don't catch anything with onUnhandledError.

Is there something misconfigured in my setup? (I started a new project using the command npm create vue@latest)

Thank you so much for your help.

Reproduction

1 - Clone the repo
2 - npm install
3 - npx vitest run --no-file-parallelism CompA

System Info

System:
    OS: macOS 26.3.1
    CPU: (12) arm64 Apple M4 Pro
    Memory: 85.34 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.22.0 - /Users/ygradaive/.nvm/versions/node/v22.22.0/bin/node
    npm: 10.9.4 - /Users/ygradaive/.nvm/versions/node/v22.22.0/bin/npm
  Browsers:
    Chrome: 145.0.7632.160
    Firefox: 148.0.2
    Firefox Developer Edition: 149.0
    Safari: 26.3.1
  npmPackages:
    @vitejs/plugin-vue: ^6.0.3 => 6.0.5 
    @vitest/coverage-v8: ^4.0.18 => 4.1.0 
    @vitest/eslint-plugin: ^1.6.6 => 1.6.11 
    @vitest/ui: ^4.0.18 => 4.1.0 
    vite: ^7.3.1 => 7.3.1 
    vitest: ^4.0.18 => 4.1.0 
    vitest-sonar-reporter: ^3.0.0 => 3.0.0

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions