Skip to content

Unable to stop runnings tests #639

@dmaretskyi

Description

@dmaretskyi

Describe the bug

The button to stop tests that are already running doesn't work.

It enough to have a single long-running test such as:

import { test } from "vitest";
import { setTimeout } from "node:timers/promises";

test("hangs", { timeout: 120_000 }, async () => {
  await setTimeout(120_000);
});

In practice, a lot of tests involving LLMs do take a long time to execute.

While the test is running I cannot run other tests.
The only workaround I've found is to restart VSCode.

Reproduction

https://github.com/dmaretskyi/vitest-vscode-plugin-hang

Exact repro steps are in the readme.

Output

[INFO 11:46:21] [v1.26.0] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 11:46:21] [API] Resolving configs: vitest-vscode-plugin-hang
[INFO 11:46:21] [API] Running Vitest v3.2.4 (vitest-vscode-plugin-hang) with "/Users/dmaretskyi/.n/bin/node /Users/dmaretskyi/.cursor/extensions/vitest.explorer-1.26.0-universal/dist/worker.js"
[INFO 11:46:21] [API] Watching 
[INFO 11:46:21] [VSCODE] Watching vitest-vscode-plugin-hang with pattern **/*
[INFO 11:46:21] [API] Collecting tests: src/hang.test.ts
[INFO 11:46:22] [Worker] Collecting src/hang.test.ts const __vite_ssr_import_0__ = await __vite_ssr_import__("/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vitest/dist/index.js", {"importedNames":["test"]});
const __vite_ssr_import_1__ = await __vite_ssr_import__("/@id/__vite-browser-external:node:timers/promises", {"importedNames":["default"]});

 const setTimeout = __vite_ssr_import_1__.default["setTimeout"];
(0,__vite_ssr_import_0__.test)("hangs", { timeout: 12e4 }, async () => {
  await setTimeout(12e4);
});

Skipping __vite_ssr_import__ (unknown call)
Skipping __vite_ssr_import__ (unknown call)
Skipping setTimeout (unknown call)
Found test hangs (run)
Found location for test hangs 5:29 -> 4:0
[11:46:22] [VSCODE] Ignoring file: src/hang.test.ts.git
[11:46:22] [VSCODE] Ignoring file: .git/FETCH_HEAD
[11:46:23] [VSCODE] Ignoring file: .git/logs/refs/remotes/origin/HEAD
[11:46:23] [VSCODE] Ignoring file: .git/refs/remotes/origin/HEAD
[11:46:23] [VSCODE] Ignoring file: .git/FETCH_HEAD
[11:46:23] [VSCODE] File deleted: .git/refs/remotes/origin/HEAD.lock
[11:46:24] [VSCODE] Ignoring file: src/hang.test.ts.git
[11:46:24] [VSCODE] Ignoring file: .git/FETCH_HEAD
[11:46:24] [VSCODE] File deleted: .git/refs/remotes/origin/HEAD.lock
[INFO 11:46:25] Running 1 file(s) with name pattern: ^\s?hangs$
[11:46:25] Starting a test run because src/hang.test.ts triggered a watch rerun event
[11:46:25] Enqueuing "hangs"
[11:46:25] No task result for "hang.test.ts", ignoring
[11:46:25] Enqueuing "hangs" because it was just collected
[11:46:25] No errors found for "hang.test.ts"
[11:46:25] Marking "hangs" as running
[11:46:25] [VSCODE] Ignoring file: src/hang.test.ts.git

Extension Version

1.26.0

Vitest Version

3.2.4

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions