Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are X handle(s) keeping the process running #4526

Closed
6 tasks done
lannuttia opened this issue Nov 17, 2023 · 4 comments
Closed
6 tasks done

There are X handle(s) keeping the process running #4526

lannuttia opened this issue Nov 17, 2023 · 4 comments
Labels
duplicate This issue or pull request already exists

Comments

@lannuttia
Copy link

lannuttia commented Nov 17, 2023

Describe the bug

This bug causes vitest to sporadically hang. In my experience it happens more frequently in my large project that uses vitest than it does in a smaller project but it will still appear in smaller projects.

 RUN  v0.34.6 /home/alannutt/Projects/lannuttia/recreate-vitest-hang
      Coverage enabled with v8

 ✓ src/app/shared/hooks/context/useToastContext.test.ts  (1 test) 43ms
 ✓ src/app/shared/hooks/useDispatchToast.test.tsx  (1 test) 353ms
 ✓ src/app/components/hoc/withTooltip.test.tsx  (5 tests) 926ms
 ✓ src/app/components/hoc/withModal.test.tsx  (5 tests) 1041ms
 ✓ src/app/components/hoc/withToast.test.tsx  (2 tests) 1469ms
 ✓ src/app/components/hoc/withDangerToast.test.tsx  (2 tests) 1495ms
 ✓ src/app/components/hoc/withSuccessToast.test.tsx  (2 tests) 1466ms
 ✓ src/app/components/providers/ToastAlertProvider.test.tsx  (20 tests) 3740ms

 Test Files  8 passed (8)
      Tests  38 passed (38)
   Start at  13:16:16
   Duration  16.49s (transform 505ms, setup 7.57s, collect 9.81s, tests 10.53s, environment 9.57s, prepare 3.82s)

 % Coverage report from v8
--------------------------|---------|----------|---------|---------|-------------------
File                      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
--------------------------|---------|----------|---------|---------|-------------------
All files                 |   97.21 |    91.37 |      95 |   97.21 |                   
 app                      |     100 |      100 |     100 |     100 |                   
  store.ts                |     100 |      100 |     100 |     100 |                   
 app/components/hoc       |    97.4 |    83.33 |     100 |    97.4 |                   
  withDangerToast.tsx     |     100 |      100 |     100 |     100 |                   
  withModal.tsx           |   95.12 |    81.81 |     100 |   95.12 | 42-43,69-70       
  withSuccessToast.tsx    |     100 |      100 |     100 |     100 |                   
  withToast.tsx           |   96.22 |       60 |     100 |   96.22 | 45-46             
  withTooltip.tsx         |     100 |      100 |     100 |     100 |                   
 app/components/providers |     100 |      100 |     100 |     100 |                   
  ToastAlertProvider.tsx  |     100 |      100 |     100 |     100 |                   
 app/shared/context       |   88.23 |      100 |       0 |   88.23 |                   
  toast-context.ts        |   88.23 |      100 |       0 |   88.23 | 13-14             
 app/shared/hooks         |     100 |      100 |     100 |     100 |                   
  useDispatchToast.ts     |     100 |      100 |     100 |     100 |                   
 app/shared/hooks/context |     100 |      100 |     100 |     100 |                   
  useToastContext.ts      |     100 |      100 |     100 |     100 |                   
 app/shared/utils         |   96.22 |      100 |     100 |   96.22 |                   
  test-utils.tsx          |   96.22 |      100 |     100 |   96.22 | 69-72             
 features/api             |     100 |      100 |     100 |     100 |                   
  emptySplitApi.ts        |     100 |      100 |     100 |     100 |                   
 i18n                     |      90 |      100 |     100 |      90 |                   
  config.ts               |      90 |      100 |     100 |      90 | 19-20             
 mocks                    |   91.66 |       80 |     100 |   91.66 |                   
  server.ts               |   91.66 |       80 |     100 |   91.66 | 17-18             
--------------------------|---------|----------|---------|---------|-------------------
There are 70 handle(s) keeping the process running

# Tinypool
node:internal/async_hooks:202                                                                                      
node:internal/async_hooks:504                                                                                      
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/tinypool/dist/esm/index.js:36           
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/tinypool/dist/esm/index.js:57           
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/tinypool/dist/esm/index.js:799          
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/vitest/dist/vendor-node.a7c48fe1.js:7314
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/vitest/dist/vendor-node.a7c48fe1.js:7676

# WORKER
node:internal/async_hooks:202                                                                                      
node:internal/worker:195                                                                                           
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/tinypool/dist/esm/index.js:536          
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/tinypool/dist/esm/index.js:521          
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/tinypool/dist/esm/index.js:506          
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/tinypool/dist/esm/index.js:804          
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/vitest/dist/vendor-node.a7c48fe1.js:7314
file:///home/alannutt/Projects/lannuttia/recreate-vitest-hang/node_modules/vitest/dist/vendor-node.a7c48fe1.js:7676

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202

# FILEHANDLE
node:internal/async_hooks:202
close timed out after 10000ms
Failed to terminate worker while running /home/alannutt/Projects/lannuttia/recreate-vitest-hang/src/app/components/hoc/withModal.test.tsx.
Tests closed successfully but something prevents Vite server from exiting
You can try to identify the cause by enabling "hanging-process" reporter. See https://vitest.dev/config/#reporters

Reproduction

An example of how to reproduce the issue can be found here.

Since this issue is sporadic it can take ~10 attempts in my experience to get it to happen. I get this to happen by running the following and waiting until eventually a run hangs.

npm ci;
for i in {1..100}; do                                                                                         
  echo "Attempt: $i";
  CI=true npm run test;
done

System Info

System:
  OS: Linux 6.5 Fedora Linux 39 (Workstation Edition)
  CPU: (12) x64 Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  Memory: 16.84 GB / 30.84 GB
  Container: Yes
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
  Yarn: 1.22.21 - ~/.nvm/versions/node/v18.18.2/bin/yarn
  npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
  pnpm: 8.10.5 - ~/.nvm/versions/node/v18.18.2/bin/pnpm
Browsers:
  Chrome: 121.0.6115.2
npmPackages:
  @vitejs/plugin-react: ^4.0.0 => 4.2.0 
  @vitest/browser: ^0.34.6 => 0.34.6 
  @vitest/coverage-v8: ^0.34.6 => 0.34.6 
  @vitest/ui: ^0.34.6 => 0.34.6 
  vite: ^4.2.1 => 4.5.0 
  vitest: ^0.34.6 => 0.34.6

Used Package Manager

npm

Validations

@AriPerkkio
Copy link
Member

Is this same as #3077? Redux toolkit seems to use fetch: https://redux-toolkit.js.org/rtk-query/api/fetchBaseQuery.

Does replacing fetch with node-fetch help? Or --no-threads or --pool=forks?

@lannuttia
Copy link
Author

It might be the same issue? I created a new issue because most of the things I'm seeing from the hanging-process reporter appears to be coming from node:internal:async_hooks and not node:child_process or node:worker_threads. I have tried using --no-threads and that did not help. As for using --pool=forks, the repository that I linked to is currently configured to use forks instead of threads. As for replacing the native node fetch with node-fetch, that is not something that is possible in projects that are using MSW 2.0 since MSW 2.0 will not support polyfilling fetch.

I'll be honest, I don't really know where exactly the actual issue is but if anyone has an idea of where it is and getting it fixed is just an issue of no one having time, I don't necessarily mind doing some leg work myself to try and get this fixed. I think vite, vitest, and msw are all fantastic tools that I would love to continue using. This issue is going to cause serious problems as people try to adopt all of these tools and unfortunately the current set of workarounds that exist don't really work for people using these tools in their software stack.

Again, I really appreciate all of the work that is being done here and don't mind doing some leg work myself to try and get this issue fixed if that's what it takes. I just actually don't know where to even start looking to try and fix this; or if people even already know that this issue exists and are working on a fix.

@AriPerkkio
Copy link
Member

the repository that I linked to is currently configured to use forks instead of threads

pool options are available only in v1-beta releases. Your project is still using 0.34.x releases:

Run npm install --save-dev vitest@beta @vitest/browser@beta @vitest/coverage-v8@beta @vitest/ui@beta and see if pool: 'forks' helps.

@AriPerkkio
Copy link
Member

This is same issue as in #3077.

I can reproduce the bug locally using the provided setup. After upgrading to Vitest v1-beta and using pool: 'forks' the issue does not reproduce anymore.

@AriPerkkio AriPerkkio closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2023
@AriPerkkio AriPerkkio added duplicate This issue or pull request already exists and removed pending triage labels Nov 19, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants