Skip to content

fix(vitest): stop propagating metadata to workers#9261

Merged
juan-fernandez merged 4 commits into
masterfrom
juan-fernandez/fix-vitest-context-bytestring
Jul 9, 2026
Merged

fix(vitest): stop propagating metadata to workers#9261
juan-fernandez merged 4 commits into
masterfrom
juan-fernandez/fix-vitest-context-bytestring

Conversation

@juan-fernandez

@juan-fernandez juan-fernandez commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Stops propagating Vitest testEnvironmentMetadata through worker providedContext.

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 testEnvironmentMetadata through Vitest providedContext so worker-reported suites could reuse main-process CI/Git metadata. That metadata can include DD_GIT_COMMIT_MESSAGE; if the commit message contains an emoji, the worker context can contain UTF-16 surrogate code units.

Under @cloudflare/vitest-pool-workers 0.12.x with Vitest 3.2.x, Vitest provided context crosses Miniflare internal fetch/Request boundaries as a header value. Undici validates request header values as ByteString, so a surrogate from the emoji-containing DD_GIT_COMMIT_MESSAGE value 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 sets DD_GIT_COMMIT_MESSAGE to a value containing an emoji to trigger the original failure deterministically.

Regression proof: temporarily restoring the old testEnvironmentMetadata handoff makes the Cloudflare/Vitest 3 integration test fail with Cannot convert argument to a ByteString... in Miniflare's Request path; 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.

@dd-octo-sts

dd-octo-sts Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.68 MB
Deduped: 7.34 MB
No deduping: 7.34 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

@datadog-official

datadog-official Bot commented Jul 8, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog auto-retried 1 job - 1 passed on retry View in Datadog

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1b2b825 | Docs | Datadog PR Page | Give us feedback!

@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/fix-vitest-context-bytestring branch from 5ea9907 to c88309b Compare July 8, 2026 15:45
@juan-fernandez juan-fernandez changed the title fix(vitest): encode provided context for workers fix(vitest): stop propagating metadata to workers Jul 8, 2026
@pr-commenter

pr-commenter Bot commented Jul 8, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-09 11:36:08

Comparing candidate commit 1b2b825 in PR branch juan-fernandez/fix-vitest-context-bytestring with baseline commit fa7a23a in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2307 metrics, 51 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-215.005ms; +209.058ms] or [-8.055%; +7.832%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-230.767ms; +235.999ms] or [-9.047%; +9.252%]

scenario:appsec-appsec-enabled-with-attacks-24

  • unstable execution_time [-162.132ms; +157.093ms] or [-5.227%; +5.065%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-188.150ms; +193.955ms] or [-6.464%; +6.664%]

scenario:appsec-control-20

  • unstable execution_time [-121.498ms; +129.847ms] or [-7.412%; +7.922%]

scenario:appsec-control-24

  • unstable execution_time [-119.508ms; +105.156ms] or [-9.695%; +8.531%]

scenario:appsec-control-26

  • unstable execution_time [-130.654ms; +121.116ms] or [-10.569%; +9.798%]

scenario:appsec-iast-no-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-13.671ms; +16.678ms] or [-5.296%; +6.461%]

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-20

  • unstable execution_time [-10.367ms; +15.602ms] or [-4.116%; +6.194%]

scenario:appsec-iast-with-vulnerability-control-20

  • unstable execution_time [-28.310ms; +30.350ms] or [-5.127%; +5.496%]

scenario:appsec-iast-with-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-29.813ms; +32.882ms] or [-5.367%; +5.919%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable execution_time [-25.043ms; +31.074ms] or [-4.581%; +5.685%]

scenario:debugger-line-probe-with-snapshot-default-24

  • unstable cpu_user_time [-2577.841ms; +3560.711ms] or [-24.218%; +33.451%]
  • unstable execution_time [-2563.309ms; +3562.505ms] or [-22.534%; +31.319%]
  • unstable instructions [-22.0G instructions; +30.6G instructions] or [-25.108%; +34.898%]
  • unstable max_rss_usage [-10.812MB; +15.726MB] or [-6.502%; +9.457%]
  • unstable throughput [-950.690op/s; +659.656op/s] or [-31.760%; +22.037%]

scenario:debugger-line-probe-with-snapshot-default-26

  • unstable cpu_user_time [-2035.213ms; +3356.901ms] or [-21.769%; +35.907%]
  • unstable execution_time [-2052.407ms; +3343.669ms] or [-20.397%; +33.230%]
  • unstable instructions [-18.2G instructions; +29.8G instructions] or [-23.419%; +38.313%]
  • unstable max_rss_usage [-5.823MB; +10.658MB] or [-3.649%; +6.679%]
  • unstable throughput [-734.188op/s; +442.091op/s] or [-22.494%; +13.545%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable cpu_user_time [-2025.436ms; +3043.208ms] or [-23.844%; +35.825%]
  • unstable execution_time [-2008.361ms; +3067.302ms] or [-21.860%; +33.386%]
  • unstable instructions [-16.9G instructions; +25.5G instructions] or [-24.390%; +36.758%]
  • unstable max_rss_usage [-8.680MB; +13.213MB] or [-5.525%; +8.410%]
  • unstable throughput [-807.230op/s; +541.570op/s] or [-22.541%; +15.123%]

scenario:debugger-line-probe-with-snapshot-minimal-26

  • unstable cpu_user_time [-1854.955ms; +577.633ms] or [-19.795%; +6.164%]
  • unstable execution_time [-1871.055ms; +570.011ms] or [-18.545%; +5.650%]
  • unstable instructions [-16.6G instructions; +5.1G instructions] or [-21.244%; +6.594%]
  • unstable throughput [-126.721op/s; +422.872op/s] or [-3.895%; +12.996%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-3079.238ms; +2346.941ms] or [-32.533%; +24.796%]
  • unstable execution_time [-3171.300ms; +2397.541ms] or [-31.172%; +23.566%]
  • unstable instructions [-26.2G instructions; +19.8G instructions] or [-33.626%; +25.443%]
  • unstable max_rss_usage [-13.919MB; +9.259MB] or [-8.612%; +5.729%]
  • unstable throughput [-641.015op/s; +835.300op/s] or [-19.292%; +25.139%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable cpu_user_time [-2.524s; +5.209s] or [-24.890%; +51.364%]
  • unstable execution_time [-2.624s; +5.307s] or [-24.109%; +48.758%]
  • unstable instructions [-21.8G instructions; +46.2G instructions] or [-25.601%; +54.313%]
  • unstable max_rss_usage [-7.486MB; +15.718MB] or [-4.649%; +9.761%]
  • unstable throughput [-1077.943op/s; +554.015op/s] or [-34.765%; +17.868%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-235.366ms; +473.942ms] or [-4.790%; +9.645%]
  • unstable execution_time [-235.840ms; +471.825ms] or [-4.726%; +9.454%]
  • unstable throughput [-162257.520op/s; +82251.887op/s] or [-9.637%; +4.885%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-24

  • unstable cpu_usage_percentage [-7.016%; +3.440%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-26

  • unstable cpu_usage_percentage [-6.046%; +4.911%]

scenario:plugin-graphql-long-with-depth-off-20

  • unstable max_rss_usage [-11.023MB; +5.287MB] or [-8.275%; +3.969%]

scenario:plugin-graphql-long-with-depth-on-max-20

  • unstable cpu_user_time [-738.748ms; +676.438ms] or [-5.795%; +5.307%]
  • unstable execution_time [-744.760ms; +685.982ms] or [-5.715%; +5.264%]
  • unstable throughput [-3.212op/s; +3.482op/s] or [-5.199%; +5.638%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-5160.285KB; +3418.618KB] or [-6.432%; +4.261%]

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.56%. Comparing base (fa7a23a) to head (1b2b825).
⚠️ Report is 1 commits behind head on master.

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     
Flag Coverage Δ
aiguard 53.62% <ø> (-0.05%) ⬇️
aiguard-integration 57.05% <ø> (ø)
apm-bucket-0 53.84% <ø> (-0.05%) ⬇️
apm-bucket-1 58.14% <ø> (-0.05%) ⬇️
apm-bucket-2 56.17% <ø> (-0.05%) ⬇️
apm-capabilities-tracing 60.24% <ø> (+<0.01%) ⬆️
apm-integrations-aerospike 53.01% <ø> (-0.05%) ⬇️
apm-integrations-confluentinc-kafka-javascript 57.05% <ø> (-0.05%) ⬇️
apm-integrations-couchbase 53.32% <ø> (-0.05%) ⬇️
apm-integrations-http 58.03% <ø> (-0.05%) ⬇️
apm-integrations-kafkajs 57.77% <ø> (+<0.01%) ⬆️
apm-integrations-next 54.30% <ø> (-0.05%) ⬇️
apm-integrations-prisma 54.23% <ø> (-0.05%) ⬇️
apm-integrations-tedious 53.09% <ø> (-0.06%) ⬇️
appsec 69.06% <ø> (-0.03%) ⬇️
appsec-express_fastify_graphql 65.67% <ø> (-0.05%) ⬇️
appsec-integration 45.59% <ø> (+<0.01%) ⬆️
appsec-kafka_ldapjs_lodash 59.16% <ø> (-0.04%) ⬇️
appsec-mongodb-core_mongoose_mysql 62.31% <ø> (-0.04%) ⬇️
appsec-next 52.90% <ø> (-0.04%) ⬇️
appsec-node-serialize_passport_postgres 61.95% <ø> (-0.04%) ⬇️
appsec-sourcing_stripe_template 60.30% <ø> (-0.04%) ⬇️
debugger 65.75% <ø> (-0.01%) ⬇️
instrumentations-bucket-0 48.81% <ø> (-0.05%) ⬇️
instrumentations-bucket-1 55.02% <ø> (-0.05%) ⬇️
instrumentations-bucket-10 56.68% <ø> (-0.05%) ⬇️
instrumentations-bucket-11 48.80% <ø> (-0.05%) ⬇️
instrumentations-bucket-12 48.90% <ø> (-0.05%) ⬇️
instrumentations-bucket-13 48.73% <ø> (-0.05%) ⬇️
instrumentations-bucket-2 49.79% <ø> (-0.05%) ⬇️
instrumentations-bucket-3 53.89% <ø> (-0.05%) ⬇️
instrumentations-bucket-4 49.22% <ø> (-0.05%) ⬇️
instrumentations-bucket-5 53.06% <ø> (-0.05%) ⬇️
instrumentations-bucket-6 55.67% <ø> (-0.05%) ⬇️
instrumentations-bucket-7 53.65% <ø> (-0.05%) ⬇️
instrumentations-bucket-8 54.69% <ø> (-0.05%) ⬇️
instrumentations-bucket-9 56.16% <ø> (-0.04%) ⬇️
instrumentations-instrumentation-couchbase 48.23% <ø> (-0.05%) ⬇️
instrumentations-integration-esbuild 33.97% <ø> (+<0.01%) ⬆️
llmobs-ai_anthropic_bedrock 57.79% <ø> (-0.04%) ⬇️
llmobs-bucket-1 57.04% <ø> (-0.04%) ⬇️
llmobs-openai 57.63% <ø> (-0.04%) ⬇️
llmobs-sdk 60.03% <ø> (-0.05%) ⬇️
llmobs-vertex-ai 54.27% <ø> (-0.05%) ⬇️
master-coverage 96.56% <ø> (?)
openfeature 54.66% <ø> (+<0.01%) ⬆️
openfeature-unit 49.88% <ø> (-0.05%) ⬇️
platform-core_esbuild_instrumentations-misc 38.44% <ø> (-0.03%) ⬇️
platform-integration 62.24% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 37.24% <ø> (-0.03%) ⬇️
plugins-bucket-0 53.23% <ø> (-0.05%) ⬇️
plugins-bucket-1 55.13% <ø> (ø)
plugins-bucket-11 55.63% <ø> (-0.05%) ⬇️
plugins-bucket-18 57.12% <ø> (-0.05%) ⬇️
plugins-bucket-19 55.44% <ø> (-0.03%) ⬇️
plugins-bucket-20 57.51% <ø> (-0.05%) ⬇️
plugins-bucket-4 53.91% <ø> (-0.05%) ⬇️
plugins-bullmq_cassandra_cookie 57.46% <ø> (-0.05%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 52.37% <ø> (-0.05%) ⬇️
plugins-fetch_fs_generic-pool 54.52% <ø> (-0.13%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 59.93% <ø> (-0.03%) ⬇️
plugins-hapi_hono_ioredis 55.92% <ø> (-0.05%) ⬇️
plugins-jest_knex_langgraph 51.72% <ø> (-0.05%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 53.47% <ø> (-0.08%) ⬇️
plugins-lodash_mariadb_memcached 54.27% <ø> (-0.05%) ⬇️
plugins-moleculer_mongodb_mongodb-core 57.35% <ø> (-0.05%) ⬇️
plugins-mongoose_multer_mysql 54.77% <ø> (-0.05%) ⬇️
plugins-mysql2_nats_node-serialize 56.27% <ø> (-0.05%) ⬇️
plugins-opensearch_passport-http_pino 55.12% <ø> (-0.05%) ⬇️
plugins-postgres_process_pug 54.35% <ø> (-0.05%) ⬇️
plugins-redis_router_sequelize 57.08% <ø> (-0.07%) ⬇️
plugins-test-and-upstream-rhea_undici_url 57.06% <ø> (-0.05%) ⬇️
plugins-valkey_vm_winston 53.99% <ø> (+0.03%) ⬆️
plugins-ws 54.86% <ø> (-0.05%) ⬇️
profiling 58.25% <ø> (-0.05%) ⬇️
serverless-aws-sdk-aws-sdk 50.71% <ø> (-0.04%) ⬇️
serverless-aws-sdk-bedrockruntime 50.73% <ø> (-0.05%) ⬇️
serverless-aws-sdk-client 52.01% <ø> (-0.05%) ⬇️
serverless-aws-sdk-dynamodb 51.80% <ø> (-0.05%) ⬇️
serverless-aws-sdk-eventbridge 46.27% <ø> (-0.05%) ⬇️
serverless-aws-sdk-kinesis 54.76% <ø> (-0.05%) ⬇️
serverless-aws-sdk-lambda 52.84% <ø> (-0.05%) ⬇️
serverless-aws-sdk-s3 51.58% <ø> (-0.05%) ⬇️
serverless-aws-sdk-serverless-peer-service 54.78% <ø> (-0.05%) ⬇️
serverless-aws-sdk-sns 55.53% <ø> (-0.05%) ⬇️
serverless-aws-sdk-sqs 55.96% <ø> (-0.05%) ⬇️
serverless-aws-sdk-stepfunctions 51.30% <ø> (-0.05%) ⬇️
serverless-aws-sdk-util 48.52% <ø> (-0.05%) ⬇️
serverless-bucket-0 55.28% <ø> (ø)
serverless-bucket-1 56.07% <ø> (-0.05%) ⬇️
test-optimization-cucumber 72.95% <ø> (-0.02%) ⬇️
test-optimization-cypress 66.47% <ø> (+0.11%) ⬆️
test-optimization-jest 73.91% <ø> (-0.03%) ⬇️
test-optimization-mocha 74.33% <ø> (+0.07%) ⬆️
test-optimization-playwright-playwright-atr 61.64% <ø> (+0.02%) ⬆️
test-optimization-playwright-playwright-efd 61.83% <ø> (+0.03%) ⬆️
test-optimization-playwright-playwright-final-status 61.78% <ø> (+0.02%) ⬆️
test-optimization-playwright-playwright-impacted-tests 61.50% <ø> (+0.19%) ⬆️
test-optimization-playwright-playwright-reporting 61.41% <ø> (+0.02%) ⬆️
test-optimization-playwright-playwright-test-management 62.54% <ø> (+0.13%) ⬆️
test-optimization-playwright-playwright-test-span 61.55% <ø> (+0.04%) ⬆️
test-optimization-selenium 60.72% <ø> (-0.14%) ⬇️
test-optimization-testopt 59.20% <ø> (+0.09%) ⬆️
test-optimization-vitest 72.58% <ø> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/fix-vitest-context-bytestring branch 2 times, most recently from e814654 to 5bfb2c1 Compare July 9, 2026 08:13
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/fix-vitest-context-bytestring branch from 5bfb2c1 to c736154 Compare July 9, 2026 08:29
@juan-fernandez
juan-fernandez marked this pull request as ready for review July 9, 2026 10:13
@juan-fernandez
juan-fernandez requested review from a team as code owners July 9, 2026 10:13
@juan-fernandez
juan-fernandez requested review from crysmags and removed request for a team July 9, 2026 10:13

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: PASS

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.

Was this helpful? React 👍 or 👎

📊 Validated against 3 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit 79ac97e · What is Autotest? · Any feedback? Reach out in #autotest

@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 79ac97eaa1

ℹ️ 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".

@juan-fernandez
juan-fernandez enabled auto-merge (squash) July 9, 2026 11:23
@juan-fernandez
juan-fernandez merged commit 7589a18 into master Jul 9, 2026
744 of 746 checks passed
@juan-fernandez
juan-fernandez deleted the juan-fernandez/fix-vitest-context-bytestring branch July 9, 2026 11:41
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: dd-trace 6.1.0 intermittently breaks Vitest tests under @cloudflare/vitest-pool-workers with ByteString header error

2 participants