11'use strict' ;
22
3+ // Flags: --expose-internals
4+
35const common = require ( '../common' ) ;
46
57common . skipIfInspectorDisabled ( ) ;
@@ -205,7 +207,7 @@ function testRunnerMain() {
205207}
206208function masterProcessMain ( ) {
207209 const workers = JSON . parse ( process . env . workers ) ;
208- const clusterSettings = JSON . parse ( process . env . clusterSettings ) ;
210+ const clusterSettings = JSON . parse ( process . env . clusterSettings ) || { } ;
209211 const badPortError = { type : RangeError , code : 'ERR_SOCKET_BAD_PORT' } ;
210212 let debugPort = process . debugPort ;
211213
@@ -224,85 +226,89 @@ function masterProcessMain() {
224226 params . expectedHost = worker . expectedHost ;
225227 }
226228
227- if ( clusterSettings ) {
228- if ( clusterSettings . inspectPort === 'addTwo' ) {
229- clusterSettings . inspectPort = common . mustCall (
230- ( ) => { return debugPort += 2 ; } ,
231- workers . length
232- ) ;
233- } else if ( clusterSettings . inspectPort === 'string' ) {
234- clusterSettings . inspectPort = 'string' ;
235- cluster . setupMaster ( clusterSettings ) ;
236-
237- common . expectsError ( ( ) => {
238- cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
239- } , badPortError ) ;
240-
241- return ;
242- } else if ( clusterSettings . inspectPort === 'null' ) {
243- clusterSettings . inspectPort = null ;
244- cluster . setupMaster ( clusterSettings ) ;
245-
246- common . expectsError ( ( ) => {
247- cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
248- } , badPortError ) ;
249-
250- return ;
251- } else if ( clusterSettings . inspectPort === 'bignumber' ) {
252- clusterSettings . inspectPort = 1293812 ;
253- cluster . setupMaster ( clusterSettings ) ;
254-
255- common . expectsError ( ( ) => {
256- cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
257- } , badPortError ) ;
258-
259- return ;
260- } else if ( clusterSettings . inspectPort === 'negativenumber' ) {
261- clusterSettings . inspectPort = - 9776 ;
262- cluster . setupMaster ( clusterSettings ) ;
263-
264- common . expectsError ( ( ) => {
265- cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
266- } , badPortError ) ;
267-
268- return ;
269- } else if ( clusterSettings . inspectPort === 'bignumberfunc' ) {
270- clusterSettings . inspectPort = common . mustCall (
271- ( ) => 123121 ,
272- workers . length
273- ) ;
274-
275- cluster . setupMaster ( clusterSettings ) ;
276-
277- common . expectsError ( ( ) => {
278- cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
279- } , badPortError ) ;
280-
281- return ;
282- } else if ( clusterSettings . inspectPort === 'strfunc' ) {
283- clusterSettings . inspectPort = common . mustCall (
284- ( ) => 'invalidPort' ,
285- workers . length
286- ) ;
287-
288- cluster . setupMaster ( clusterSettings ) ;
289-
290- common . expectsError ( ( ) => {
291- cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
292- } , badPortError ) ;
293-
294- return ;
295- }
229+ clusterSettings . execArgv = clusterSettings . execArgv ?
230+ clusterSettings . execArgv . concat ( [ '--expose-internals' ] ) :
231+ process . execArgv . concat ( [ '--expose-internals' ] ) ;
232+
233+ if ( clusterSettings . inspectPort === 'addTwo' ) {
234+ clusterSettings . inspectPort = common . mustCall (
235+ ( ) => { return debugPort += 2 ; } ,
236+ workers . length
237+ ) ;
238+ } else if ( clusterSettings . inspectPort === 'string' ) {
239+ clusterSettings . inspectPort = 'string' ;
240+ cluster . setupMaster ( clusterSettings ) ;
241+
242+ common . expectsError ( ( ) => {
243+ cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
244+ } , badPortError ) ;
245+
246+ return ;
247+ } else if ( clusterSettings . inspectPort === 'null' ) {
248+ clusterSettings . inspectPort = null ;
296249 cluster . setupMaster ( clusterSettings ) ;
250+
251+ common . expectsError ( ( ) => {
252+ cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
253+ } , badPortError ) ;
254+
255+ return ;
256+ } else if ( clusterSettings . inspectPort === 'bignumber' ) {
257+ clusterSettings . inspectPort = 1293812 ;
258+ cluster . setupMaster ( clusterSettings ) ;
259+
260+ common . expectsError ( ( ) => {
261+ cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
262+ } , badPortError ) ;
263+
264+ return ;
265+ } else if ( clusterSettings . inspectPort === 'negativenumber' ) {
266+ clusterSettings . inspectPort = - 9776 ;
267+ cluster . setupMaster ( clusterSettings ) ;
268+
269+ common . expectsError ( ( ) => {
270+ cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
271+ } , badPortError ) ;
272+
273+ return ;
274+ } else if ( clusterSettings . inspectPort === 'bignumberfunc' ) {
275+ clusterSettings . inspectPort = common . mustCall (
276+ ( ) => 123121 ,
277+ workers . length
278+ ) ;
279+
280+ cluster . setupMaster ( clusterSettings ) ;
281+
282+ common . expectsError ( ( ) => {
283+ cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
284+ } , badPortError ) ;
285+
286+ return ;
287+ } else if ( clusterSettings . inspectPort === 'strfunc' ) {
288+ clusterSettings . inspectPort = common . mustCall (
289+ ( ) => 'invalidPort' ,
290+ workers . length
291+ ) ;
292+
293+ cluster . setupMaster ( clusterSettings ) ;
294+
295+ common . expectsError ( ( ) => {
296+ cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
297+ } , badPortError ) ;
298+
299+ return ;
297300 }
298301
302+ cluster . setupMaster ( clusterSettings ) ;
303+
299304 cluster . fork ( params ) . on ( 'exit' , common . mustCall ( checkExitCode ) ) ;
300305 }
301306}
302307
303308function workerProcessMain ( ) {
304309 const { expectedPort, expectedInitialPort, expectedHost } = process . env ;
305- const debugOptions = process . binding ( 'config' ) . debugOptions ;
310+ const debugOptions =
311+ require ( 'internal/options' ) . getOptionValue ( '--inspect-port' ) ;
306312
307313 if ( 'expectedPort' in process . env ) {
308314 assert . strictEqual ( process . debugPort , + expectedPort ) ;
@@ -327,7 +333,7 @@ function spawnMaster({ execArgv, workers, clusterSettings = {} }) {
327333 clusterSettings : JSON . stringify ( clusterSettings ) ,
328334 testProcess : true
329335 } ) ,
330- execArgv
336+ execArgv : execArgv . concat ( [ '--expose-internals' ] )
331337 } ) . on ( 'exit' , common . mustCall ( ( code , signal ) => {
332338 checkExitCode ( code , signal ) ;
333339 resolve ( ) ;
0 commit comments