Skip to content

Tests time out too early on WSL #8276

@DonaldDuck313

Description

@DonaldDuck313

Describe the bug

I've set the tests to time out after 60 seconds. My tests run for about 50 seconds total (one and a half second per test), but still time out:

$ vitest unittest/test.test.js --run --test-timeout=60000

 RUN  v3.0.9 /mnt/c/Users/dduck/Documents/test

 ❯ test.test.js (35 tests | 1 failed) 49700ms
   ✓ Math.random() 1416ms
   ✓ Math.random() 1382ms
   ✓ Math.random() 1321ms
   ✓ Math.random() 1362ms
   ✓ Math.random() 1427ms
   ✓ Math.random() 1458ms
   ✓ Math.random() 1436ms
   ✓ Math.random() 1463ms
   ✓ Math.random() 1868ms
   ✓ Math.random() 1563ms
   ✓ Math.random() 1517ms
   ✓ Math.random() 1471ms
   ✓ Math.random() 1371ms
   ✓ Math.random() 1401ms
   ✓ Math.random() 1356ms
   ✓ Math.random() 1419ms
   ✓ Math.random() 1374ms
   ✓ Math.random() 1349ms
   ✓ Math.random() 1311ms
   ✓ Math.random() 1371ms
   ✓ Math.random() 1498ms
   ✓ Math.random() 1467ms
   ✓ Math.random() 1496ms
   ✓ Math.random() 1329ms
   ✓ Math.random() 1318ms
   ✓ Math.random() 1351ms
   × Math.random() 1367ms
     → Test timed out in 60000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
   ✓ Math.random() 1500ms
   ✓ Math.random() 1411ms
   ✓ Math.random() 1450ms
   ✓ Math.random() 1476ms
   ✓ Math.random() 1358ms
   ✓ Math.random() 1354ms
   ✓ Math.random() 1337ms
   ✓ Math.random() 1348ms

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  unittest/test.test.js > Math.random()
Error: Test timed out in 60000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯


 Test Files  1 failed (1)
      Tests  1 failed | 34 passed (35)
   Start at  08:59:30
   Duration  50.47s (transform 88ms, setup 0ms, collect 80ms, tests 49.70s, environment 0ms, prepare 157ms)

(All the failures are incorrect timeouts, no tests actually fail)

This seems like a bug, it's not possible that any test timed out after 60 seconds since the total test time was 50 seconds, and the test that timed out only ran for 1367 milliseconds.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-8g35cv8t?file=repro.test.js

Download and unzip test.test.zip (sorry for not providing the js file directly, github doesn't seem to allow that). Run it on a Windows Subsystem for Linux with vitest unittest/test.test.js --run --test-timeout=60000. Depending on how fast your computer is, you may need to adjust the timeout, the number of tests, or the iterations variable. You might also need to run the tests several times, this doesn't happen at every run.

System Info

System:
    OS: Linux 6.6 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (8) x64 AMD Ryzen 5 7520U with Radeon Graphics
    Memory: 5.99 GB / 6.68 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 23.5.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 11.4.2 - /usr/bin/npm
    pnpm: 9.15.2 - /usr/bin/pnpm
  npmPackages:
    vite: 6.2.x => 6.2.7
    vitest: 3.0.x => 3.0.9

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

Labels

p3-minor-bugAn edge case that only affects very specific usage (priority)

Type

Projects

Status

Discussing

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions