vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
13.15k stars 1.19k forks source link

[Linux] cannot terminate running test with await #6886

Closed mskonovalov closed 2 weeks ago

mskonovalov commented 2 weeks ago

Describe the bug

On Linux if I run a test that contains some async/await code, it cannot be stopped rather than with kill -9.

Reproduction

describe('aaa', () => {
  it('should work', async () => {
    while (true) {
      logger.info('123123');
      await new Promise(resolve => setTimeout(resolve, 1000));
    }
  });
});

if I remove the timeout, all works just fine. ALSO --pool=threads works fine as well.

https://github.com/user-attachments/assets/3df1bdae-d7d2-4451-b7ec-21e63f00392e

System Info

"vitest": "2.1.1"
Ubuntu 20.04
Node 20.17

Used Package Manager

yarn

Validations

hi-ogawa commented 2 weeks ago

I couldn't reproduce with your code on my Linux PC. Just in case, can you provide a repro as git repo? Looks like you have workspace and maybe some special reporters.

Btw, I see something like this in the terminal:

$ pnpm -C examples/basic test repro

> @vitest/example-test@ test /home/hiroshi/code/others/vitest/examples/basic
> vitest "repro"

 DEV  v2.1.4 /home/hiroshi/code/others/vitest/examples/basic

stdout | test/repro.test.ts > aaa > should work
123123

stdout | test/repro.test.ts > aaa > should work
123123

stdout | test/repro.test.ts > aaa > should work
123123

Cancelling test run. Press CTRL+c again to exit forcefully.   /// 👈 Ctrl+C 1st time

stdout | test/repro.test.ts > aaa > should work
123123

 ❯ test/repro.test.ts (1)
   ❯ aaa (1)
     ⠋ should work
 ELIFECYCLE  Test failed. See above for more details.  /// 👈 Ctrl+C 2nd time
github-actions[bot] commented 2 weeks ago

Hello @mskonovalov. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.