test_runner: avoid hanging on incomplete v8 frames#62704
test_runner: avoid hanging on incomplete v8 frames#62704thisalihassan wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
| // size, causing #processRawBuffer to make no progress and | ||
| // #drainRawBuffer to loop forever without the no-progress guard. | ||
| const reported = await collectReported([oversizedLengthHeader]); | ||
| assert(reported.every((event) => event.type === 'test:stdout')); |
There was a problem hiding this comment.
We can get a much more useful error output by using partialDeepStrictEqual here
| assert(reported.every((event) => event.type === 'test:stdout')); | |
| assert.partialDeepStrictEqual(reported, Array.from({ length: reported.length }, () => ({ type: 'test:stdout' })); |
| data: { | ||
| __proto__: null, | ||
| file: this.name, | ||
| message: TypedArrayPrototypeSubarray(bufferHead, 0, 1).toString('utf-8'), |
There was a problem hiding this comment.
If we're dealing with a single-byte UTF-8 char, we don't need the intermediate view I think
| message: TypedArrayPrototypeSubarray(bufferHead, 0, 1).toString('utf-8'), | |
| message: StringFromCharCode(bufferHead[0]), |
There was a problem hiding this comment.
it changes the output semantics here StringFromCharCode(0xff) gives "ÿ" but Buffer.from([0xff]).toString('utf8') gives "�" which matches the current stdout path so I’m keeping the UTF-8 decode
There was a problem hiding this comment.
String.fromCodePoint then – but I'm surprised we would get non-ASCII chars here
Signed-off-by: Ali Hassan <ali-hassan27@outlook.com>
631f70a to
825b3e3
Compare
|
Can you add a proper PR description? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62704 +/- ##
==========================================
- Coverage 89.80% 89.79% -0.02%
==========================================
Files 699 699
Lines 216363 216416 +53
Branches 41370 41370
==========================================
+ Hits 194309 194333 +24
- Misses 14140 14187 +47
+ Partials 7914 7896 -18
🚀 New features to boost your workflow:
|
The test runner could hang while draining child stdout when the buffered data started with bytes that matched the V8 serializer header (
0xff 0x0f) but did not contain a complete serialized frame.In that case
#processRawBuffer()made no progress, and#drainRawBuffer()kept calling it in a loop forever.This change makes the deserializer recover from that end-of-stream case by flushing the buffered bytes as stdout and continuing to resync. It also preserves the ordering of a trailing partial V8 header split across chunks.
Closes #62693
Assisted-by: Claude Opus