-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: child process queue pending messages
It fixes the problem for the child process not receiving messages. Fixes: #41134
- Loading branch information
1 parent
0d9f3bd
commit 100b785
Showing
2 changed files
with
43 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
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,19 @@ | ||
import '../common/index.mjs'; | ||
import assert from 'assert'; | ||
import { fork } from 'child_process'; | ||
import { once } from 'events'; | ||
|
||
if (process.argv[2] !== 'child') { | ||
const currentFile = 'test-esm-child-process-fork-main.mjs'; | ||
const { pathname: filename } = new URL(currentFile, 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(); | ||
} else { | ||
process.on('message', (msg) => process.send(msg)); | ||
} |