Skip to content

Commit e123a52

Browse files
committed
debugger: end connections used to check availability of the port
The debugger check the availability of the specified inspector server port by trying to connect to it, and retry if the connection can be established (which means the port is not yet free), but it never ends those connections. This patch adds code to end the connections after they are established to avoid taking up more resources than necessary.
1 parent 2ac729f commit e123a52

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/internal/debugger/inspect.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ async function portIsFree(host, port, timeout = 3000) {
6464
const error = await new Promise((resolve) => {
6565
const socket = net.connect(port, host);
6666
socket.on('error', resolve);
67-
socket.on('connect', resolve);
67+
socket.on('connect', () => {
68+
socket.end();
69+
resolve();
70+
});
6871
});
6972
if (error?.code === 'ECONNREFUSED') {
7073
return;

0 commit comments

Comments
 (0)