From 9aec1ddb4f8862b1e0f521e76ca84f4727d06bce 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(); + })); +}