Skip to content

Commit a0ee55d

Browse files
Disable dynamic import for unix-dgram causing memory leak
nodejs/node#42080 vercel/next.js#34659 (comment)
1 parent 564ac7b commit a0ee55d

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

lib/transport.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ const dgram = require('dgram');
33
const net = require('net');
44
const dns = require('dns');
55
const { PROTOCOL } = require('./constants');
6-
7-
// Imported below, only if needed
8-
let unixDgram;
6+
const unixDgram = require('unix-dgram');
97

108
const UDS_PATH_DEFAULT = '/var/run/datadog/dsd.socket';
119

@@ -87,16 +85,6 @@ const createUdpTransport = args => {
8785
};
8886

8987
const createUdsTransport = args => {
90-
try {
91-
// This will not always be available, as noted in the error message below
92-
unixDgram = require('unix-dgram'); // eslint-disable-line global-require
93-
} catch (err) {
94-
throw new Error(
95-
'The library `unix_dgram`, needed for the uds protocol to work, is not installed. ' +
96-
'You need to pick another protocol to use hot-shots. ' +
97-
'See the hot-shots README for additional details.'
98-
);
99-
}
10088
const udsPath = args.path ? args.path : UDS_PATH_DEFAULT;
10189
const socket = unixDgram.createSocket('unix_dgram');
10290

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
"lint": "eslint lib/**/*.js test/**/*.js",
3535
"pretest": "npm run lint"
3636
},
37-
"optionalDependencies": {
38-
"unix-dgram": "2.0.x"
39-
},
37+
"optionalDependencies": {},
4038
"devDependencies": {
4139
"eslint": "5.9.x",
4240
"mocha": "6.2.x",
4341
"nyc": "15.x"
4442
},
4543
"license": "MIT",
46-
"dependencies": {}
44+
"dependencies": {
45+
"unix-dgram": "2.0.x"
46+
}
4747
}

0 commit comments

Comments
 (0)