Skip to content

Commit

Permalink
test: test cluster worker disconnection on error
Browse files Browse the repository at this point in the history
This test checks that ownerless cluster worker handles are closed
correctly on disconnection.

Fixes: #6561
PR-URL: #6909
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
santigimeno authored and cjihrig committed May 24, 2016
1 parent aadfe6c commit f0a07d9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/parallel/test-cluster-worker-disconnect-on-error.js
Original file line number Diff line number Diff line change
@@ -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();
}));
}

0 comments on commit f0a07d9

Please sign in to comment.