@@ -21,10 +21,10 @@ const diagnosticEvent = {
2121const chunks = await toArray(serializer([diagnosticEvent]));
2222const defaultSerializer = new DefaultSerializer();
2323defaultSerializer.writeHeader();
24- const headerLength = defaultSerializer.releaseBuffer().length ;
25- const headerOnly = Buffer.from([0xff, 0x0f]) ;
26- const oversizedLengthHeader = Buffer.from([0xff, 0x0f, 0x7f, 0xff, 0xff, 0xff]);
27- const truncatedLengthHeader = Buffer.from([0xff, 0x0f, 0x00, 0x01, 0x00, 0x00]);
24+ const headerOnly = Buffer.from( defaultSerializer.releaseBuffer()) ;
25+ const headerLength = headerOnly.length ;
26+ const oversizedLengthHeader = Buffer.concat([headerOnly, Buffer.from([ 0x7f, 0xff, 0xff, 0xff]) ]);
27+ const truncatedLengthHeader = Buffer.concat([headerOnly, Buffer.from([ 0x00, 0x01, 0x00, 0x00]) ]);
2828// Expected stdout for oversizedLengthHeader: first byte is emitted via
2929// String.fromCharCode (byte-by-byte fallback in #drainRawBuffer), remaining
3030// bytes go through the nonSerialized UTF-8 decode path in #processRawBuffer.
@@ -94,10 +94,10 @@ describe('v8 deserializer', common.mustCall(() => {
9494
9595 it('should not hang when buffer starts with v8Header followed by oversized length', async () => {
9696 // Regression test for https://github.com/nodejs/node/issues/62693
97- // FF 0F is the v8 serializer header; the next 4 bytes are read as a
98- // big-endian message size. 0x7FFFFFFF far exceeds any actual buffer
99- // size, causing #processRawBuffer to make no progress and
100- // #drainRawBuffer to loop forever without the no-progress guard.
97+ // The v8 serializer header is followed by 4 bytes read as a big-endian
98+ // message size. 0x7FFFFFFF far exceeds any actual buffer size, causing
99+ // #processRawBuffer to make no progress and #drainRawBuffer to loop
100+ // forever without the no-progress guard.
101101 const reported = await collectReported([oversizedLengthHeader]);
102102 assert.partialDeepStrictEqual(
103103 reported,
@@ -117,14 +117,14 @@ describe('v8 deserializer', common.mustCall(() => {
117117 });
118118
119119 it('should flush v8Header-only bytes as stdout when stream ends', async () => {
120- // Just the two-byte v8 header with no size field at all.
120+ // Just the v8 header bytes with no size field at all.
121121 const reported = await collectReported([headerOnly]);
122122 assert(reported.every((event) => event.type === 'test:stdout'));
123123 assert.strictEqual(collectStdout(reported), headerOnly.toString('latin1'));
124124 });
125125
126126 it('should resync and parse valid messages after false v8 header', async () => {
127- // A false v8 header (FF 0F + oversized length) followed by a
127+ // A false v8 header (header bytes + oversized length) followed by a
128128 // legitimate serialized message. The parser must skip the corrupt
129129 // bytes and still deserialize the real message.
130130 const reported = await collectReported([
0 commit comments