Skip to content

New pool implementation: Timeout terminating forks worker for test files (v4) #8766

Closed

Description

@kleinfreund

Describe the bug

Following #8649 and the new pool implementation, I start to see short-running tests start to fail due to running longer than the default 5s test timeout with the following errors:

Test failure output:

Error: Test timed out in 5000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".

After run output:

[vitest-pool]: Timeout terminating forks worker for test files /Users/project/test.spec.ts.
[vitest-pool]: Failed to terminate forks worker for test files /Users/project/test.spec.ts. Error: [vitest-pool-runner]: Timeout waiting for worker to respond
    at Timeout.<anonymous> (file:///Users/project/node_modules/vitest/dist/chunks/cli-api.BjHteKX0.js:6531:58)
    at listOnTimeout (node:internal/timers:608:17)
    at process.processTimers (node:internal/timers:543:7)

Additionally, after this issue occurs, node processes remain active that quickly consume a lot of processing power which results in my laptop's fans to spin loudly (which they almost never do).

Reproduction

https://github.com/kleinfreund/vitest-reproduction/tree/new-pool-implementation

Identical to the reproduction provided in #8649 with a new branch new-pool-implementation that only upgrades vitest from 4.0.0-beta.13 to 4.0.0.

System Info

Binaries:
    Node: 24.9.0 - ~/.local/share/mise/installs/node/24.9.0/bin/node
  npmPackages:
    @vitejs/plugin-vue: 6.0.1 => 6.0.1 
    vite: 7.1.7 => 7.1.7 
    vitest: 4.0.0 => 4.0.0

Used Package Manager

npm

Validations

Activity

  1. added theissue type on Oct 22, 2025
  2. changed the title [-]New pool implementation: Timeout terminating forks worker for test files[/-] [+]New pool implementation: Timeout terminating forks worker for test files (v4)[/+] on Oct 22, 2025
  3. sheremet-va commented on Oct 22, 2025

    @sheremet-va
    Member

    Adding wrapper.unmount to every test fixes this for me. What is the reason that you don't cleanup resources automatically?

    The fetch error indicates there was something happening after the test finished running. It's not a global fetch, it's an internal RPC channel being closed. Sometimes it correctly points to the source 😄

    Error: [vitest-worker]: Closing rpc while "fetch" was pending
     ❯ reviveInvokeError node_modules/vite/dist/node/module-runner.js:474:14
     ❯ Object.invoke node_modules/vite/dist/node/module-runner.js:490:33
     ❯ VitestModuleRunner.getModuleInformation node_modules/vite/dist/node/module-runner.js:1053:7
     ❯ request node_modules/vite/dist/node/module-runner.js:1070:83
     ❯ src/ViewTwo.vue:3:31
          1| <template>
          2|   <p>Two</p>
          3|   <button @click="$router.push('/')">Go</button>
           |                               ^
          4| </template>
          5| 
     ❯ VitestModuleEvaluator.runInlinedModule node_modules/vitest/dist/module-evaluator.js:136:4
     ❯ VitestModuleRunner.directRequest node_modules/vite/dist/node/module-runner.js:1113:59
     ❯ VitestModuleRunner.cachedRequest node_modules/vite/dist/node/module-runner.js:1031:73
    
  4. sheremet-va commented on Oct 22, 2025

    @sheremet-va
    Member

    I think I found a way to fix it, but we can't fix your tests being flaky. You are asynchronously loading a new route after the test has finished running, so you might get history is not defined for example. To fix this, you need to unmount components.

    At least, the hanging will be gone.

  5. kleinfreund commented on Oct 22, 2025

    @kleinfreund
    ContributorAuthor

    Adding wrapper.unmount to every test fixes this for me. What is the reason that you don't cleanup resources automatically?

    Good point! The private project I initially encountered this issue in uses

    enableAutoUnmount(afterEach);

    from @vue/test-utils in its vitest setup file which I missed in the reproduction. Adding it does indeed stabilize the tests.

  6. kleinfreund commented on Oct 23, 2025

    @kleinfreund
    ContributorAuthor

    Although extremely rarely in a project with 81 tests, I do still occasionally have some tests time out at the default 5 seconds with

    Error: Test timed out in 5000ms.
    If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
    

    From what I can tell, it's exactly those tests that would've caused the issues as initially reported in this issue. There's no other error output anymore (as of 4.0.1), but I think it's a relatively good bet that it's tests in which there are network requests pending as a test completes.

    I'll try and reproduce this in isolation, but the issue is so rare in the project with 81 tests that, presumably, it's too rare in the reproduction to be meaningfully reproducable. So far, I didn't manage and I ran the reproduction tests several dozen times.

  7. silverwind commented on Oct 23, 2025

    @silverwind
    Contributor

    In one of my repos on v4, I see persistent timeout being hit after like 100s for tests the completed within 1 second in v3. I have configured testTimeout: 30000, so I find it odd that it can even keep running that long.

  8. locked and limited conversation to collaborators on Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions