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