mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
de12141dd0
It fixes the problem of the child process not receiving messages. Fixes: https://github.com/nodejs/node/issues/41134 PR-URL: https://github.com/nodejs/node/pull/41221 Reviewed-By: Adrian Estrada <edsadr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
21 lines
549 B
JavaScript
21 lines
549 B
JavaScript
import '../common/index.mjs';
|
|
import assert from 'assert';
|
|
import { fork } from 'child_process';
|
|
import { once } from 'events';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
if (process.argv[2] !== 'child') {
|
|
const filename = fileURLToPath(import.meta.url);
|
|
const cp = fork(filename, ['child']);
|
|
const message = 'Hello World';
|
|
cp.send(message);
|
|
|
|
const [received] = await once(cp, 'message');
|
|
assert.deepStrictEqual(received, message);
|
|
|
|
cp.disconnect();
|
|
await once(cp, 'exit');
|
|
} else {
|
|
process.on('message', (msg) => process.send(msg));
|
|
}
|