@@ -46,9 +46,8 @@ if (!id) {
46
46
47
47
48
48
a . on ( 'message' , common . mustCall ( ( m ) => {
49
- if ( typeof m === 'object' ) return ;
50
- assert . strictEqual ( m , 'READY' ) ;
51
- b . send ( 'START' ) ;
49
+ assert . strictEqual ( m . msg , 'READY' ) ;
50
+ b . send ( { msg : 'START' , port : m . port } ) ;
52
51
} ) ) ;
53
52
54
53
b . on ( 'message' , common . mustCall ( ( m ) => {
@@ -60,10 +59,10 @@ if (!id) {
60
59
} else if ( id === 'one' ) {
61
60
if ( cluster . isMaster ) return startWorker ( ) ;
62
61
63
- http . createServer ( common . mustNotCall ( ) )
64
- . listen ( common . PORT , common . mustCall ( ( ) => {
65
- process . send ( 'READY' ) ;
66
- } ) ) ;
62
+ const server = http . createServer ( common . mustNotCall ( ) ) ;
63
+ server . listen ( 0 , common . mustCall ( ( ) => {
64
+ process . send ( { msg : 'READY' , port : server . address ( ) . port } ) ;
65
+ } ) ) ;
67
66
68
67
process . on ( 'message' , common . mustCall ( ( m ) => {
69
68
if ( m === 'QUIT' ) process . exit ( ) ;
@@ -74,8 +73,8 @@ if (!id) {
74
73
const server = http . createServer ( common . mustNotCall ( ) ) ;
75
74
process . on ( 'message' , common . mustCall ( ( m ) => {
76
75
if ( m === 'QUIT' ) process . exit ( ) ;
77
- assert . strictEqual ( m , 'START' ) ;
78
- server . listen ( common . PORT , common . mustNotCall ( ) ) ;
76
+ assert . strictEqual ( m . msg , 'START' ) ;
77
+ server . listen ( m . port , common . mustNotCall ( ) ) ;
79
78
server . on ( 'error' , common . mustCall ( ( e ) => {
80
79
assert . strictEqual ( e . code , 'EADDRINUSE' ) ;
81
80
process . send ( e . code ) ;
0 commit comments