Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/internal/child_process/serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ const advanced = {
*parseChannelMessages(channel, readData) {
if (readData.length === 0) return;

ArrayPrototypePush(channel[kMessageBuffer], readData);
if (channel[kMessageBufferSize] && channel[kMessageBuffer][0].length < 4) {
// Message length split into two buffers, so let's concatenate it.
channel[kMessageBuffer][0] = Buffer.concat([channel[kMessageBuffer][0], readData]);
} else {
ArrayPrototypePush(channel[kMessageBuffer], readData);
}
channel[kMessageBufferSize] += readData.length;

// Index 0 should always be present because we just pushed data into it.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';
const common = require('../common');
const child_process = require('child_process');

// Regression test for https://github.com/nodejs/node/issues/55834
const msgLen = 65521;
let cnt = 10;

if (process.argv[2] === 'child') {
const msg = Buffer.allocUnsafe(msgLen);
(function send() {
if (cnt--) {
process.send(msg, send);
} else {
process.disconnect();
}
})()

Check failure on line 17 in test/parallel/test-child-process-advanced-serialization-splitted-length-field.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon
} else {
const child = child_process.spawn(process.execPath, [__filename, 'child'], {
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
serialization: 'advanced'
});
child.on('message', common.mustCall(cnt));
}
Loading