-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cluster: don't send messages if no IPC channel
Avoid sending messages if the IPC channel is already disconnected. It avoids undesired errors when calling `process.disconnect` when there are still pending IPC messages. PR-URL: #7132 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
1 parent
97b50d3
commit 4602d10
Showing
2 changed files
with
21 additions
and
0 deletions.
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,18 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cluster = require('cluster'); | ||
|
||
if (cluster.isMaster) { | ||
const worker = cluster.fork(); | ||
worker.on('exit', common.mustCall((code, signal) => { | ||
assert.strictEqual(code, 0, 'worker did not exit normally'); | ||
assert.strictEqual(signal, null, 'worker did not exit normally'); | ||
})); | ||
} else { | ||
const net = require('net'); | ||
const server = net.createServer(); | ||
server.listen(common.PORT, common.mustCall(() => { | ||
process.disconnect(); | ||
})); | ||
} |