fix(vitest): stop propagating metadata to workers#9261
Conversation
Overall package sizeSelf size: 6.68 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.1 | 122.62 kB | 437.94 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 🔄 Datadog auto-retried 1 job - 1 passed on retry 🔗 Commit SHA: 1b2b825 | Docs | Datadog PR Page | Give us feedback! |
5ea9907 to
c88309b
Compare
BenchmarksBenchmark execution time: 2026-07-09 11:36:08 Comparing candidate commit 1b2b825 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2307 metrics, 51 unstable metrics.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9261 +/- ##
==========================================
+ Coverage 96.55% 96.56% +0.01%
==========================================
Files 918 918
Lines 121410 121396 -14
Branches 20874 20664 -210
==========================================
- Hits 117231 117230 -1
+ Misses 4179 4166 -13 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:
|
e814654 to
5bfb2c1
Compare
5bfb2c1 to
c736154
Compare
There was a problem hiding this comment.
More details
This PR correctly fixes a ByteString validation error in Cloudflare worker pools by stopping propagation of testEnvironmentMetadata through Vitest's providedContext. The fix is safe: workers never accessed this field, and the main process retains its own metadata for backfilling git tags onto worker traces during span preparation. Test coverage includes a regression test with emoji-containing commit messages that would have failed before the fix.
📊 Validated against 3 scenarios · Open Bits AI session
🤖 Datadog Autotest · Commit 79ac97e · What is Autotest? · Any feedback? Reach out in #autotest
|
@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". |
What does this PR do?
Stops propagating Vitest
testEnvironmentMetadatathrough workerprovidedContext.Vitest worker context still carries the IDs, command, repository root, and CODEOWNERS entries needed to attach worker-reported suites to the main test session. Worker-created spans keep using their local Test Optimization metadata, while the main process still uses its own metadata for DI log export and backfills
git.*tags onto worker traces.Motivation
Fixes #9259.
The regression was caused by commit
63c2b0c2c(fix(test-optimization): propagate vitest worker metadata), which was part of PR #9193: #9193.That change started sending
testEnvironmentMetadatathrough VitestprovidedContextso worker-reported suites could reuse main-process CI/Git metadata. That metadata can includeDD_GIT_COMMIT_MESSAGE; if the commit message contains an emoji, the worker context can contain UTF-16 surrogate code units.Under
@cloudflare/vitest-pool-workers0.12.x with Vitest 3.2.x, Vitest provided context crosses Miniflare internalfetch/Requestboundaries as a header value. Undici validates request header values asByteString, so a surrogate from the emoji-containingDD_GIT_COMMIT_MESSAGEvalue can throw before tests start.Additional Notes
Added a regression test using
[email protected]with@cloudflare/[email protected], matching the affected Vitest 3 Cloudflare worker-pool path. The test setsDD_GIT_COMMIT_MESSAGEto a value containing an emoji to trigger the original failure deterministically.Regression proof: temporarily restoring the old
testEnvironmentMetadatahandoff makes the Cloudflare/Vitest 3 integration test fail withCannot convert argument to a ByteString...in Miniflare'sRequestpath; removing the handoff makes it pass.Local validation also covered linting for the touched files and test-script coverage for the new fixture. Full repo lint is still blocked locally by the existing vendor dependency state:
vendor/node_modules/@apm-js-collab/[email protected]is marked invalid for^0.15.0.