Repository navigation
fix(vitest): flush worker traces before file completion - #11394
juan-fernandez wants to merge 2 commits into
Conversation
Overall package sizeSelf size: 9.56 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.3 | 131.25 kB | 531.9 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11394 +/- ##
========================================
Coverage 99.15% 99.15%
========================================
Files 1136 1136
Lines 188132 188445 +313
Branches 86 86
========================================
+ Hits 186543 186861 +318
+ Misses 1589 1584 -5
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:
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 31bcddb | Docs | View more details | Give us feedback! |
BenchmarksBenchmark execution time: 2026-11-24 08:53:55 Comparing candidate commit 31bcddb in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2480 metrics, 7 unstable metrics.
|
What does this PR do?
Send each completed Vitest trace as a plain object through the existing worker IPC transport. This avoids the file-sized JSON buffer and removes the parent process's two JSON parses per trace message. Final flushing waits for outstanding IPC sends.
Convert tracer IDs to hex strings before sending. Apply the previous JSON conversion to individual spans with non-finite metrics, negative zero, structured metadata, or span events. That preserves null for non-finite metrics and JSON's nested value conversion, including
toJSON()hooks.Motivation
Fixes #11390. A file's accumulated trace JSON can exceed V8's maximum string length, dropping all test and suite events. Early Flake Detection retries amplify the payload and keep affected tests from becoming known.
Additional Notes
Benchmark
Compared the final native IPC implementation with the previous per-trace JSON version of this PR (
082d7f73b6) and a prototype that parses JSON once. Six trials per variant and pool ran on arm64 macOS with Node 24.14.1 and Vitest 5.1.1. Each run used one worker with isolation disabled, 32 new tests with 550 child spans each, and three EFD retries. Every run delivered 129 test events with distinct trace IDs, 70,400 child spans, and one suite, module, and session event to the mock intake.The time and peak RSS columns report medians. The percentage changes use the previous JSON path as the baseline. An initial codec screen found that MessagePack reduced wire size but added CPU cost. Sending eight traces per message also raised peak memory for large traces, so the Vitest worker sends one trace per message.
Validation
npm run lintandgit diff --checkpassed.npm run lint:editorconfigrequires a running Docker daemon, which was unavailable.