From fd86b3f64c9a258781d5633443c6f3ecb45a3172 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Sat, 21 May 2016 15:54:30 +0200 Subject: [PATCH] test: verify IPC messages are emitted on next tick The test in this commit runs correctly if IPC messages are properly consumed and emitted. Otherwise, the test times out. Fixes: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6909 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- test/parallel/test-cluster-ipc-throw.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/parallel/test-cluster-ipc-throw.js diff --git a/test/parallel/test-cluster-ipc-throw.js b/test/parallel/test-cluster-ipc-throw.js new file mode 100644 index 00000000000000..f2e7f2822c7315 --- /dev/null +++ b/test/parallel/test-cluster-ipc-throw.js @@ -0,0 +1,23 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); +const cluster = require('cluster'); + +cluster.schedulingPolicy = cluster.SCHED_RR; + +const server = http.createServer(); + +if (cluster.isMaster) { + server.listen(common.PORT); + const worker = cluster.fork(); + worker.on('exit', common.mustCall(() => { + server.close(); + })); +} else { + process.on('uncaughtException', common.mustCall((e) => {})); + server.listen(common.PORT); + server.on('error', common.mustCall((e) => { + cluster.worker.disconnect(); + throw e; + })); +}