Vitest hangs tests, close timed out after 1000ms

See original GitHub issue

Describe the bug

Started encountering our tests hanging with the message close timed out after 1000ms, a google search lead to this issue, tried everything in there with no success, for us is still hit or miss whether we get the error on not.

We get the error on different machines and also CI.

Reproduction

https://stackblitz.com/edit/vitejs-vite-brwl54?file=package.json

System Info

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 133.73 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 3.2.0 - ~/.nvm/versions/node/v16.14.0/bin/yarn
    npm: 8.9.0 - ~/.nvm/versions/node/v16.14.0/bin/npm
  Browsers:
    Chrome: 105.0.5195.102
    Firefox: 101.0.1
    Safari: 15.5

Used Package Manager

npm

Validations

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:13
  • Comments:23 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
silverwindcommented, Dec 5, 2022

I happen to have one case where it reproduces locally, in a around 1 in 10 runs. When it happens, the node process goes to 100% cpu and hangs forever. I managed to hook up the inspector:

image

processReallyExit is from module signal-exit module which vitest has multiple dependencies on:

vitest@0.25.3
├─┬ @antfu/install-pkg@0.1.1
│ └─┬ execa@5.1.1
│   └── signal-exit@3.0.7
├─┬ execa@6.1.0
│ └── signal-exit@3.0.7
└─┬ log-update@5.0.1
  └─┬ cli-cursor@4.0.0
    └─┬ restore-cursor@4.0.0
      └── signal-exit@3.0.7

reallyExit is a undocumented node internal which apparently is being monkey-patched by signal-exit.

2reactions
silverwindcommented, Nov 8, 2022

Seeing this “close timed out after 1000ms” message on Drone CI as well. Test run still succeeds, and all tests are very simple unit tests, nothing fancy, nothing that would keep the event loop alive so I assume any open handles must be inside vitest itself.

Does unfortunately not reproduce locally, even with CI variable set.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stuck in ci: close timed out after 1000ms · Issue #1288 - GitHub
Describe the bug Runing with vitest run --coverage. All tests passed and coverage is generated, while the process stucks.
Read more >
API Reference | Vitest
It receives the test name, an async function with the tests to collect, and an optional timeout (in milliseconds). ts
Read more >
JUnit Test "Times Out" Despite Executing Quickly?
This is an issue with JUnit. In fact, the 'test timed out' message appears if there is an InterruptedException :
Read more >
Async Methods - Testing Library
These can be useful to wait for an element to appear or disappear in response to an event, user action, timeout, or Promise....
Read more >
Vitest (@vitest_dev) / Twitter
Builtin typechecking with expectTypeOf! onTestFailed hook to capture internal closure 🗺️ Better sourcemap support Big shout out to @sheremet_va who ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found