fix(vitest): route thread workers through main process#9169
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 |
|
BenchmarksBenchmark execution time: 2026-07-01 10:27:33 Comparing candidate commit 00b50d9 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2249 metrics, 37 unstable metrics.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1d375adc8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9169 +/- ##
==========================================
- Coverage 93.73% 93.72% -0.02%
==========================================
Files 892 892
Lines 51236 51311 +75
Branches 11924 11945 +21
==========================================
+ Hits 48026 48089 +63
- Misses 3210 3222 +12 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:
|
There was a problem hiding this comment.
More details
The getWrappedOn refactor is the most load-bearing correctness decision in this PR: the new global MessagePort.prototype.on wrapping (wrapMessagePortOn) would have swallowed ALL of Vitest's own array messages on any MessagePort if the old "always return for arrays" logic had been kept — the selective handleWorkerReport-based early return is what makes the global wrap safe.
📊 Validated against 41 scenarios · Open Bits AI session
🤖 Datadog Autotest · Commit d1d375a · What is Autotest? · Any feedback? Reach out in #autotest
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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". |
What does this PR do?
Routes Vitest thread-pool workers through the Test Optimization test-worker exporter so they report back to the Vitest main process instead of reporting directly to the intake or Datadog Agent.
This updates the legacy Tinypool instrumentation to mark Vitest worker environments before eager workers are spawned, adds a Vitest worker MessagePort path for legacy thread workers, and tightens Vitest integration coverage so both
forksandthreadsmust be reported as framework worker events.Motivation
Vitest
forksworkers already usedci-visibility/exporters/test-worker, and Vitest 4 thread workers behaved correctly. Older Vitest thread workers did not get a worker-identifying environment marker, sodd-trace/ci/initselected the normal exporter and those workers reported directly.The root cause is that legacy Tinypool thread workers do not expose
TINYPOOL_WORKER_IDinprocess.env, and Vitest 1.x/2.x do not export theVitestclass from the CLI chunk where ourrunFileswrapper attaches. Marking the Tinypool worker options before construction gives all supported Vitest worker pools the same reporting behavior.