Skip to content

testTimeout is not fully respected: Error: [vitest-worker]: Timeout calling "onTaskUpdate" #8164

@andruhon

Description

@andruhon

Describe the bug

Error: [vitest-worker]: Timeout calling "onTaskUpdate"

Following on #4497

I'm using vitest to run integration tests.

I have the following configuration for my integration tests:

import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    include: ['integration-tests/**/*.it.ts'],
    environment: 'node',
    globals: true,
    testTimeout: 1000 * 60 * 2,
  },
});

Note that the timeout is set to 2 minutes.

The following error is displayed when one of the individual tests takes longer than 60 seconds to run.

Error: [vitest-worker]: Timeout calling "onTaskUpdate"                                                                                                                                                                              
 ❯ Object.onTimeoutError node_modules/vitest/dist/chunks/rpc.Iovn4oWe.js:56:10
 ❯ Timeout._onTimeout node_modules/vitest/dist/chunks/index.CJ0plNrh.js:60:62
 ❯ listOnTimeout node:internal/timers:588:17
 ❯ processTimers node:internal/timers:523:7

It appears that https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/runtime/workers/forks.ts
simply passes v8 from 'node:v8' to createForksRpcOptions,
this in turn goes to https://github.com/antfu/birpc/blob/3a78f95f7e7f04b3d7b111540ff4ba41ea1a010f/src/index.ts#L192
v8 does not seem to have timeout and consequently createBirpc uses DEFAULT_TIMEOUT which is 60 seconds.

This causes Timeout calling "onTaskUpdate" to be displayed even though the testTimeout is set to 2 minutes and the test actually passes.

The test in trouble

https://github.com/andruhon/gaunt-sloth-assistant/blob/eda76fa89dab2f87d8c5f6078e60e38044e5dd7e/integration-tests/prCommand.it.ts

The test attempts to do a GitHub PR review and check it against GitHub issue as requirements.
Test uses real LLM, and at some times of a day LLMs are quite slow to respond, and the test sometimes takes a bit more than a minute.

As you can see in the output below, due to testTimeout the test actually passes, but the error is displayed.

 ✓ integration-tests/prCommand.it.ts (2 tests) 75517ms                                                                                                                                                                              
   ✓ PR Command Integration Tests > should approve PR #39 with issue #23  64763ms                                                                                                                                                   
   ✓ PR Command Integration Tests > should reject PR #1  10754ms                                                                                                                                                                    
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 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: [vitest-worker]: Timeout calling "onTaskUpdate"                                                                                                                                                                              
 ❯ Object.onTimeoutError node_modules/vitest/dist/chunks/rpc.Iovn4oWe.js:53:10
 ❯ Timeout._onTimeout node_modules/vitest/dist/chunks/index.CJ0plNrh.js:57:62
 ❯ listOnTimeout node:internal/timers:588:17
 ❯ processTimers node:internal/timers:523:7

I can potentially create a PR improving that, or will be happy to take advice if I am misusing vitest.

Reproduction

  • set timeout to 2 minutes
  • create test which runs a bit longer than a minute
  • run test
  • observe error

Particular test in trouble https://github.com/andruhon/gaunt-sloth-assistant/blob/eda76fa89dab2f87d8c5f6078e60e38044e5dd7e/integration-tests/prCommand.it.ts

Runner command:
https://github.com/andruhon/gaunt-sloth-assistant/blob/eda76fa89dab2f87d8c5f6078e60e38044e5dd7e/integration-tests/support/commandRunner.ts

(updated to point to old unfixed commit using exec sync)

System Info

(observed the same on Windows, WSL, Mac and Linux)

  System:
    OS: Linux 5.15 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
    CPU: (22) x64 Intel(R) Core(TM) Ultra 7 155H
    Memory: 14.10 GB / 15.36 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.15.0 - ~/.nvm/versions/node/v22.15.0/bin/node
    npm: 11.4.1 - ~/.nvm/versions/node/v22.15.0/bin/npm
  npmPackages:
    vitest: ^3.2.3 => 3.2.3

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-edge-caseBug, but has workaround or limited in scope (priority)pending triage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions