@@ -75,13 +75,12 @@ const {
75
75
ERR_SOCKET_BAD_PORT ,
76
76
ERR_SOCKET_CLOSED
77
77
} = errors . codes ;
78
- const dns = require ( 'dns' ) ;
79
78
80
79
const kLastWriteQueueSize = Symbol ( 'lastWriteQueueSize' ) ;
81
80
82
- // `cluster` is only used by `listenInCluster` so for startup performance
83
- // reasons it's lazy loaded.
84
- var cluster = null ;
81
+ // Lazy loaded to improve startup performance.
82
+ let cluster ;
83
+ let dns ;
85
84
86
85
const errnoException = errors . errnoException ;
87
86
const exceptionWithHostPort = errors . exceptionWithHostPort ;
@@ -1034,6 +1033,8 @@ function lookupAndConnect(self, options) {
1034
1033
throw new ERR_INVALID_ARG_TYPE ( 'options.lookup' ,
1035
1034
'Function' , options . lookup ) ;
1036
1035
1036
+
1037
+ if ( dns === undefined ) dns = require ( 'dns' ) ;
1037
1038
var dnsopts = {
1038
1039
family : options . family ,
1039
1040
hints : options . hints || 0
@@ -1368,7 +1369,7 @@ function listenInCluster(server, address, port, addressType,
1368
1369
backlog , fd , exclusive ) {
1369
1370
exclusive = ! ! exclusive ;
1370
1371
1371
- if ( cluster === null ) cluster = require ( 'cluster' ) ;
1372
+ if ( cluster === undefined ) cluster = require ( 'cluster' ) ;
1372
1373
1373
1374
if ( cluster . isMaster || exclusive ) {
1374
1375
// Will create a new handle
@@ -1482,6 +1483,7 @@ Server.prototype.listen = function(...args) {
1482
1483
} ;
1483
1484
1484
1485
function lookupAndListen ( self , port , address , backlog , exclusive ) {
1486
+ if ( dns === undefined ) dns = require ( 'dns' ) ;
1485
1487
dns . lookup ( address , function doListen ( err , ip , addressType ) {
1486
1488
if ( err ) {
1487
1489
self . emit ( 'error' , err ) ;
0 commit comments