test_runner: do not crash on stdout that mimics a v8 frame #66273
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.45) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 436 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.364
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #66273"
general
weight: 0.35
MoLow
Summary
node --testcan crash the parent runner when a test writes bytes to stdout that look like a v8 report frame. A singleconsole.logof the wrong bytes aborts the whole run with an internal error that does not point at any test:Fixes: #66164
Root cause
The child test process multiplexes framed report messages and raw user stdout on one pipe. A frame starts with the two magic bytes
FF 0Ffollowed by a 4 byte size.#processRawBufferscans for that magic, reads the size and hands the payload to the v8 deserializer. User output can contain those same bytes, so stray stdout with a plausible size reaches the deserializer, which throws. The call had no error handling, so the exception aborted the entire run. The earlier>>> 0fix in #64706 hardened the size read only. This case has a valid looking size and fails one step later at the deserialize.Fix
The reporter writes each frame as a v8 header, a 4 byte size, then a second v8 header, then the serialized value. So a real frame always repeats the
FF 0Fheader at the start of its payload.#processRawBuffernow uses that structure instead of a blanket catch:1. Validate before deserializing. A candidate is handed to the deserializer only when its payload is long enough and begins with the inner v8 header. Stray stdout that only mimics a frame fails this check and is emitted as stdout. A genuine frame with a valid inner header that still fails to deserialize is left to throw, so a real regression in the report protocol surfaces instead of being hidden.
2. Resync live. When the bytes only mimic a frame, one byte is emitted as stdout and the header search restarts right away, so a real frame that follows stray bytes is reported immediately instead of waiting for shutdown.
3. Single loop.
#processRawBufferis now one loop that inspects the head of the buffer on each pass and handles exactly one case: leading stdout, an incomplete frame, a frame that only mimics the header, or a real frame. This replaces the earlier nested loops and the mimicsFrame flag.This turns a fatal crash into recoverable stdout, keeps any real frames that follow the stray bytes and surfaces genuine deserialize failures.
Tests
Added cases to
test/parallel/test-runner-v8-deserializer.mjs:drain()Known limitation (possible follow-up, out of scope here)
For stray bytes to be misread now they would have to reproduce the full frame shape, the outer header, a matching size, the inner header, then a valid serialized payload. This is pre-existing and extremely unlikely. Fully removing the ambiguity needs an escape mechanism or a separate channel for user stdout, which is a larger change. This PR removes the crash, which is the reported bug.