11'use strict' ;
22
33const {
4- Map,
4+ ArrayPrototypeJoin,
5+ FunctionPrototype,
56 ObjectAssign,
7+ ReflectApply,
8+ SafeMap,
69} = primordials ;
710
811const assert = require ( 'internal/assert' ) ;
@@ -12,9 +15,9 @@ const { owner_symbol } = require('internal/async_hooks').symbols;
1215const Worker = require ( 'internal/cluster/worker' ) ;
1316const { internal, sendHelper } = require ( 'internal/cluster/utils' ) ;
1417const cluster = new EventEmitter ( ) ;
15- const handles = new Map ( ) ;
16- const indexes = new Map ( ) ;
17- const noop = ( ) => { } ;
18+ const handles = new SafeMap ( ) ;
19+ const indexes = new SafeMap ( ) ;
20+ const noop = FunctionPrototype ;
1821
1922module . exports = cluster ;
2023
@@ -49,7 +52,7 @@ cluster._setupWorker = function() {
4952 if ( message . act === 'newconn' )
5053 onconnection ( message , handle ) ;
5154 else if ( message . act === 'disconnect' )
52- _disconnect . call ( worker , true ) ;
55+ ReflectApply ( _disconnect , worker , [ true ] ) ;
5356 }
5457} ;
5558
@@ -62,10 +65,13 @@ cluster._getServer = function(obj, options, cb) {
6265 process . platform !== 'win32' )
6366 address = path . resolve ( address ) ;
6467
65- const indexesKey = [ address ,
66- options . port ,
67- options . addressType ,
68- options . fd ] . join ( ':' ) ;
68+ const indexesKey = ArrayPrototypeJoin (
69+ [
70+ address ,
71+ options . port ,
72+ options . addressType ,
73+ options . fd ,
74+ ] , ':' ) ;
6975
7076 let index = indexes . get ( indexesKey ) ;
7177
@@ -119,7 +125,7 @@ function shared(message, handle, indexesKey, cb) {
119125 send ( { act : 'close' , key } ) ;
120126 handles . delete ( key ) ;
121127 indexes . delete ( indexesKey ) ;
122- return close . apply ( handle , arguments ) ;
128+ return ReflectApply ( close , handle , arguments ) ;
123129 } ;
124130 assert ( handles . has ( key ) === false ) ;
125131 handles . set ( key , handle ) ;
@@ -228,9 +234,9 @@ function _disconnect(masterInitiated) {
228234
229235// Extend generic Worker with methods specific to worker processes.
230236Worker . prototype . disconnect = function ( ) {
231- if ( ! [ 'disconnecting' , 'destroying' ] . includes ( this . state ) ) {
237+ if ( this . state !== 'disconnecting' && this . state !== 'destroying' ) {
232238 this . state = 'disconnecting' ;
233- _disconnect . call ( this ) ;
239+ ReflectApply ( _disconnect , this , [ ] ) ;
234240 }
235241
236242 return this ;
0 commit comments