-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
child_process: fix parsing messages with splitted length field
Fixes: #55834 PR-URL: #56106 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/parallel/test-child-process-advanced-serialization-splitted-length-field.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
})(); | ||
} else { | ||
const child = child_process.spawn(process.execPath, [__filename, 'child'], { | ||
stdio: ['inherit', 'inherit', 'inherit', 'ipc'], | ||
serialization: 'advanced' | ||
}); | ||
child.on('message', common.mustCall(cnt)); | ||
} |