1'use strict'; 2const common = require('../common'); 3const cluster = require('cluster'); 4const assert = require('assert'); 5 6common.skipIfInspectorDisabled(); 7 8checkForInspectSupport('--inspect'); 9 10function checkForInspectSupport(flag) { 11 12 const nodeOptions = JSON.stringify(flag); 13 const numWorkers = 2; 14 process.env.NODE_OPTIONS = flag; 15 16 if (cluster.isPrimary) { 17 for (let i = 0; i < numWorkers; i++) { 18 cluster.fork(); 19 } 20 21 cluster.on('online', (worker) => { 22 worker.disconnect(); 23 }); 24 25 cluster.on('exit', common.mustCall((worker, code, signal) => { 26 const errMsg = `For NODE_OPTIONS ${nodeOptions}, failed to start cluster`; 27 assert.strictEqual(worker.exitedAfterDisconnect, true, errMsg); 28 }, numWorkers)); 29 } 30} 31