chore: upgrade Vitest to v4 - #497
Conversation
Release runs nx run-many across every package at nx.json parallel: 5. That oversubscribes GitHub-hosted runners and flakes two test:lib jobs: - @tanstack/devtools-ui: default 5s timeout on Solid + goober mounts - @tanstack/devtools: vitest worker RPC stall (onTaskUpdate) PR already caps NX_PARALLEL at 3 (#478). Apply the same cap to Release, and raise the 30s test/hook timeouts on the remaining heavy UI packages.
📝 WalkthroughWalkthroughThe project migrates to Vitest 4, adds package-specific test projects, disables Solid HMR during tests, updates affected test mocks and timers, and limits Nx release parallelism to 3. ChangesVitest 4 migration and test execution
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 8dbdde6
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/angular-devtools
@tanstack/devtools
@tanstack/devtools-a11y
@tanstack/devtools-bundler-core
@tanstack/devtools-client
@tanstack/devtools-rspack
@tanstack/devtools-ui
@tanstack/devtools-utils
@tanstack/devtools-vite
@tanstack/devtools-event-bus
@tanstack/devtools-event-client
@tanstack/preact-devtools
@tanstack/react-devtools
@tanstack/solid-devtools
@tanstack/svelte-devtools
@tanstack/vue-devtools
commit: |
Bump vitest from 3.2.4 to 4.1.10. Vitest 4 replaces the 60s onTaskUpdate RPC timeout that failed Release after every @tanstack/devtools test had already passed. Migrate defineWorkspace to test.projects. Turn off Solid HMR in tests so the module runner does not load /@solid-refresh. Update mocks and timers that Vitest 4 types or isolates differently.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/event-bus-client/tests/index.test.ts`:
- Around line 12-24: Update the test setup around bus.start and afterEach to
track every disposer returned by client.on, onAll, and onAllPluginEvents, then
invoke all stored disposers before clearing timers. Ensure the disposer
collection is reset per test so EventClient subscriptions do not leak between
tests.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6da7bdcb-1056-46f6-ac3d-a6cdddc4588e
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (17)
examples/react/bundling-repro/package.jsonexamples/react/start/package.jsonpackage.jsonpackages/angular-devtools/package.jsonpackages/devtools-a11y/vite.config.tspackages/devtools-ui/vite.config.tspackages/devtools-utils/vite.config.solid-class.tspackages/devtools-utils/vite.config.solid.tspackages/devtools-vite/tests/index.test.tspackages/devtools/tests/index.test.tspackages/devtools/vite.config.tspackages/event-bus-client/tests/index.test.tspackages/react-devtools/tests/devtools.test.tsxpackages/solid-devtools/vite.config.tstsconfig.jsonvitest.config.tsvitest.workspace.js
💤 Files with no reviewable changes (1)
- vitest.workspace.js
| // EventClient starts reconnect intervals and has no public stop. | ||
| // Fake timers so each test owns those intervals and leftover | ||
| // `tanstack-connect` events do not leak into the next test. | ||
| vi.useFakeTimers() | ||
| bus = new ClientEventBus() | ||
| bus.start() | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| // Clean up after each test | ||
| bus.stop() | ||
| vi.clearAllTimers() | ||
| vi.useRealTimers() | ||
| vi.restoreAllMocks() |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
file='packages/event-bus-client/tests/index.test.ts'
rg -n -C 3 \
'new EventClient|\.on(All|AllPluginEvents)?\(|cleanup\(\)|afterEach|bus\.stop|clearAllTimers' \
"$file"Repository: TanStack/devtools
Length of output: 9723
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- test structure and teardown ---'
cat -n packages/event-bus-client/tests/index.test.ts | sed -n '1,540p'
printf '%s\n' '--- EventClient subscription implementation ---'
fd -i 'plugin.ts' packages/event-bus-client
rg -n -C 6 'class EventClient|onAllPluginEvents|onAll\(|on\(' packages/event-bus-client/src packages/event-bus-client/testsRepository: TanStack/devtools
Length of output: 43631
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- EventClient listener registration and disposal ---'
cat -n packages/event-bus-client/src/plugin.ts | sed -n '40,315p'
printf '%s\n' '--- ClientEventBus event lifecycle ---'
rg -n -C 8 'tanstack-connect|tanstack-connect-success|tanstack-devtools-global|tanstack-dispatch-event|addEventListener|removeEventListener' packages/event-bus-client packages/event-bus/src packages --glob '*.ts' --glob '*.tsx' | sed -n '1,260p'
printf '%s\n' '--- Subscription calls and disposer usage by test line ---'
python3 - <<'PY'
import re
from pathlib import Path
path = Path('packages/event-bus-client/tests/index.test.ts')
lines = path.read_text().splitlines()
for i, line in enumerate(lines, 1):
if re.search(r'\.on(?:AllPluginEvents|All)?\s*\(', line):
print(f'{i}: {line.strip()}')
window = '\n'.join(lines[i-1:min(i+8, len(lines))])
if re.search(r'\b(?:cleanup|off|dispose)\s*\(\)', window):
print(' disposer call found nearby')
else:
print(' no disposer call found nearby')
PYRepository: TanStack/devtools
Length of output: 31325
Clean up all EventClient subscriptions between tests.
Several calls to client.on(...), onAll(...), and onAllPluginEvents(...) discard their disposer. These listeners remain on window after afterEach, so later tests can invoke earlier handlers. Store and call each disposer before timer cleanup.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/event-bus-client/tests/index.test.ts` around lines 12 - 24, Update
the test setup around bus.start and afterEach to track every disposer returned
by client.on, onAll, and onAllPluginEvents, then invoke all stored disposers
before clearing timers. Ensure the disposer collection is reset per test so
EventClient subscriptions do not leak between tests.
Changes
Upgrade Vitest from 3.2.4 to 4.1.10.
The Release
test:cijob failed after every@tanstack/devtoolstest had already passed. Vitest 3 has a hard 60s worker RPC timeout ononTaskUpdate. The workbench suite takes longer than that on a loaded GitHub runner. RaisingtestTimeoutdoes not change that RPC limit. Vitest 4 removes it.This PR also keeps the earlier CI load changes:
NX_PARALLELat 3 on Release (same as PR).testTimeout/hookTimeoutto 30s on@tanstack/devtools-uiand@tanstack/devtools-a11y.Vitest 4 migration
defineWorkspace/vitest.workspace.jswithtest.projectsinvitest.config.ts.hot: process.env.VITEST !== 'true'). Vitest 4's module runner treats/@solid-refreshasfile:///@solid-refreshand throws.new.@tanstack/devtools-event-clientso EventClient reconnect intervals do not leak.mountDevtoolsexport. A file-levelvi.mockdoes not wrapimport('./mount-impl')incore.ts.console.logspies the real log signature. A barevi.fn()is also typed as a constructor in Vitest 4.Checklist
pnpm test:prrelated checks.Locally:
nx run-many -t test:lib --exclude=examples/**— 16 packages green, including@tanstack/devtools323/323 (workbench 44 tests, noonTaskUpdatetimeout).nx run-many -t test:types --exclude=examples/**— green.Release Impact
Summary by CodeRabbit
Bug Fixes
Chores