@@ -19,8 +19,9 @@ const PipeConnectWrap = process.binding('pipe_wrap').PipeConnectWrap;
19
19
const ShutdownWrap = process . binding ( 'stream_wrap' ) . ShutdownWrap ;
20
20
const WriteWrap = process . binding ( 'stream_wrap' ) . WriteWrap ;
21
21
22
-
23
22
var cluster ;
23
+ var dns ;
24
+
24
25
const errnoException = util . _errnoException ;
25
26
const exceptionWithHostPort = util . _exceptionWithHostPort ;
26
27
const isLegalPort = internalNet . isLegalPort ;
@@ -948,7 +949,7 @@ function realConnect(options, cb) {
948
949
949
950
950
951
function lookupAndConnect ( self , options ) {
951
- const dns = require ( 'dns' ) ;
952
+ const dns = lazyDns ( ) ;
952
953
var host = options . host || 'localhost' ;
953
954
var port = options . port ;
954
955
var localAddress = options . localAddress ;
@@ -1286,6 +1287,13 @@ function emitListeningNT(self) {
1286
1287
}
1287
1288
1288
1289
1290
+ function lazyDns ( ) {
1291
+ if ( dns === undefined )
1292
+ dns = require ( 'dns' ) ;
1293
+ return dns ;
1294
+ }
1295
+
1296
+
1289
1297
function listenInCluster ( server , address , port , addressType ,
1290
1298
backlog , fd , exclusive ) {
1291
1299
exclusive = ! ! exclusive ;
@@ -1414,7 +1422,7 @@ Server.prototype.listen = function() {
1414
1422
} ;
1415
1423
1416
1424
function lookupAndListen ( self , port , address , backlog , exclusive ) {
1417
- const dns = require ( 'dns' ) ;
1425
+ const dns = lazyDns ( ) ;
1418
1426
dns . lookup ( address , function doListen ( err , ip , addressType ) {
1419
1427
if ( err ) {
1420
1428
self . emit ( 'error' , err ) ;
0 commit comments