Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@
*parseChannelMessages(channel, readData) {
if (readData.length === 0) return;

ArrayPrototypePush(channel[kMessageBuffer], readData);
if (channel[kMessageBuffer].length && channel[kMessageBuffer][0].length < 4) {
// message length splitted into two buffers, so let's concat it

Check failure on line 65 in lib/internal/child_process/serialization.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Comments should not begin with a lowercase character
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,26 @@
'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.nextTick(() => {
process.exit(0);
});

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

Trailing spaces not allowed
}
})()

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

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Trailing spaces not allowed

Check failure on line 19 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