Skip to content

v4: inconsistent errors with pool: 'forks' or 'vmForks' #8861

@its2easy

Description

@its2easy

Describe the bug

I have a vue 3/ts/vuetify project with some tests and they break in random places after vitest@4 update. I've found that pool: 'threads' and 'vmThreads' are ok, while pool: 'forks' or 'vmForks' trigger the errors. fileParallelism: false or maxWorkers: 1 make forks work correctly, same as running only one test file.

Not every run ends with errors, sometimes all the tests go well. The errors are like:
SyntaxError: Unexpected end of input
SyntaxError: Unexpected token '}'
SyntaxError: missing ) after argument list
SyntaxError: Missing initializer in const declaration
TypeError: (0 , vite_ssr_import_3.genericComponent) is not a function
TypeError: (0 , vite_ssr_import_2.createVuetify) is not a function
TypeError: (0 , vite_ssr_import_1.createVuetifyAdapter) is not a function
TypeError: (0 , vite_ssr_import_1.createDefaults) is not a function
TypeError: (0 , vite_ssr_import_1.someFunctionFromProjectImportedInTestFile) is not a function

I made a small reproduction, but the smaller the project the harder it is to trigger an error. In the reproduction repo I can get errors after importing the result of createVuetify function in at least 2 test files, or while importing it in 1 test file while using vuetify component in a project component. But in the original project the errors are reproducible even when running a subset of the test files for simple functions, so it doesn't look like a vuetify problem

Reproduction

https://github.com/its2easy/vitest4-error
Run npm test or npm run test:50 to run the tests 50 times in a row (sometimes the error may appear 1/2 runs, and sometimes it's 1/30)

btw I couldn't reproduce the errors on StackBlitz

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
    Memory: 14.13 GB / 31.37 GB
  Binaries:
    Node: 24.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.6.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 141.0.7390.108
    Edge: Chromium (140.0.3485.54)
    Firefox: 144.0.2 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.26100.1882

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