Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 60eab91

Browse filesBrowse files
BridgeARMylesBorins
authored andcommitted
dns: lazy loaded
PR-URL: #20567 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent 28d00a1 commit 60eab91
Copy full SHA for 60eab91

File tree

Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Open diff view settings
Collapse file

‎lib/dgram.js‎

Copy file name to clipboardExpand all lines: lib/dgram.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const {
3535
ERR_SOCKET_DGRAM_NOT_RUNNING
3636
} = errors.codes;
3737
const { Buffer } = require('buffer');
38-
const dns = require('dns');
3938
const util = require('util');
4039
const { isUint8Array } = require('internal/util/types');
4140
const EventEmitter = require('events');
@@ -47,6 +46,9 @@ const { UV_UDP_REUSEADDR } = process.binding('constants').os;
4746

4847
const { UDP, SendWrap } = process.binding('udp_wrap');
4948

49+
// Lazy load for startup performance.
50+
let dns;
51+
5052
const BIND_STATE_UNBOUND = 0;
5153
const BIND_STATE_BINDING = 1;
5254
const BIND_STATE_BOUND = 2;
@@ -72,9 +74,10 @@ function lookup6(lookup, address, callback) {
7274

7375

7476
function newHandle(type, lookup) {
75-
if (lookup === undefined)
77+
if (lookup === undefined) {
78+
if (dns === undefined) dns = require('dns');
7679
lookup = dns.lookup;
77-
else if (typeof lookup !== 'function')
80+
} else if (typeof lookup !== 'function')
7881
throw new ERR_INVALID_ARG_TYPE('lookup', 'Function', lookup);
7982

8083
if (type === 'udp4') {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.