refactor(vitest): split main and worker instrumentation#9170
Conversation
Overall package sizeSelf size: 6.43 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.2.0 | 104.26 kB | 843.44 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 2476014 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-07-01 10:43:55 Comparing candidate commit 2476014 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2255 metrics, 31 unstable metrics.
|
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (87.03%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #9170 +/- ##
=======================================
Coverage 93.71% 93.72%
=======================================
Files 892 895 +3
Lines 51311 51324 +13
Branches 11945 11947 +2
=======================================
+ Hits 48087 48101 +14
+ Misses 3224 3223 -1 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
634acea to
e6abd9f
Compare
e6abd9f to
2476014
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
More details
All 15 addHook registrations from the original vitest.js are accounted for (11 in vitest-main.js, 4 in vitest-worker.js). Channel identity is preserved via Node.js module caching of vitest-util.js, and realSetTimeout is captured at line 4 of vitest-worker.js before any test can install fake timers. 26 adversarial scenarios covering isFlakyTestRetriesEnabledForTask, getTypeTasks, getTestName, getProvidedContext failure paths, and dispatcher routing all passed cleanly.
📊 Validated against 26 scenarios · Open Bits AI session
🤖 Datadog Autotest · Commit 2476014 · What is Autotest? · Any feedback? Reach out in #autotest
What does this PR do?
Splits the Vitest instrumentation into process-specific modules on top of #9169:
vitest.jsis now a small dispatcher that loads the worker module whenDD_VITEST_WORKER=1, otherwise the main-process module.vitest-main.jsowns session setup/finish, sequencer wrapping, coverage wrapping, Tinypool and Vitest pool worker setup, and worker-report handling.vitest-worker.jsowns@vitest/runnerhooks, test/test-suite lifecycle publication, retry handling, EFD, Test Management, and Failed Test Replay worker behavior.vitest-util.jscontains shared channels and small Vitest helper functions used by both sides.Motivation
With #9169 making
DD_VITEST_WORKERreliably available for every supported Vitest worker, the instrumentation now has a stable boundary between main-process hooks and worker-process hooks. Splitting the file makes that boundary explicit and keeps future changes from mixing worker test lifecycle behavior with main-process worker transport setup.