From 74dce1bf9458406b9548afba16438ddaeb117071 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Mon, 23 May 2016 20:04:24 +0200 Subject: [PATCH] test: test cluster worker disconnection on error This test checks that ownerless cluster worker handles are closed correctly on disconnection. 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-cluster-worker-disconnect-on-error.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/parallel/test-cluster-worker-disconnect-on-error.js diff --git a/test/parallel/test-cluster-worker-disconnect-on-error.js b/test/parallel/test-cluster-worker-disconnect-on-error.js new file mode 100644 index 00000000000000..e52f7ddee60993 --- /dev/null +++ b/test/parallel/test-cluster-worker-disconnect-on-error.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); +const cluster = require('cluster'); + +cluster.schedulingPolicy = cluster.SCHED_NONE; + +const server = http.createServer(); +if (cluster.isMaster) { + server.listen(common.PORT); + const worker = cluster.fork(); + worker.on('exit', common.mustCall(() => { + server.close(); + })); +} else { + server.listen(common.PORT); + server.on('error', common.mustCall((e) => { + cluster.worker.disconnect(); + })); +}