fix!: change default pool to 'forks'#5047
Conversation
✅ Deploy Preview for fastidious-cascaron-4ded94 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I'm not familiar with entire story of When people are thinking to migrate from more old-ish test framework to either Jest or Vitest, hitting this minor stability issue of the default setting could potentially move some people away from Vitest. |
By the way, Jest also has an option for switching I was also able to reproduce process hangs on Jest using their |
|
Been using forks for a long time now without any issues to avoid the hangs, so I think it'd be a good default. |
d2fda64 to
86b688d
Compare
|
I shared this before but here is a Github search result of |
c8a4e21 to
b591930
Compare
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
|
Can you resolve the conflicts, please? 👀 |
b591930 to
1effe5b
Compare
|
Some new errors after rebase 🤔 Oh right, this one is showing up: tinylibs/tinypool#85. Time to update Tinypool to Vitest's repo. |
b932703 to
7e6de16
Compare
7e6de16 to
a6d4fc6
Compare
|
FYI, the test runs in my enterprise project became significantly slower with forks. 342 tests in 152 files. Mostly using +Many test timed out now after reaching the 5s default test time out. Can I provide you with more data? |
Sure, would be interesting to see why NodeJS becomes that much slower with multi-processing instead of multi-threading. We've also mentioned this on https://vitest.dev/guide/improving-performance.html#pool but we've never seen that much of an impact. Please create new issue with reproduction: https://github.com/vitest-dev/vitest/issues/new/choose |
Description
Switches default
pooloption from'threads'to'forks'. Adds new documentation pages describing common errors withpool: 'threads': segfaults and process hangs.Motivation
Main goal is to provide stability over small performance boosts.
The
pool: 'threads'runs code innode:worker_threads,pool: 'forks'runs code innode:child_process. While threads may be slightly faster than forks, it has been causing bugs that are very difficult to debug. Typically these errors are coming when users' test code contains native node module (e.g. Node packages that utilize C++, Go, Rust via Node-API).There are also some NodeJS bugs in
node:worker_threadsthat can lead toWorker's being stuck. So far I've been able to reproduce these issues by using Node's nativefetch,dompurifyandfastify.All the cases mentioned above and links below work fine when using
pool: 'forks'.Segfaults and other native module crashes:
Process hangs:
Related issues:
fetchcan makeworker_threadsstuck and process hang nodejs/undici#2026Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.