Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2022-08-24 16:52:54 +0300
committerJuan José Arboleda <soyjuanarbol@gmail.com>2022-10-11 22:45:18 +0300
commitf717c1e06ac7e2420a16e6c3dfa61a4edaf66fc3 (patch)
tree254dc86d249524ce3048bc95424ad7e5a51c5d22 /lib
parent59be5f89ca4aa6ba8d8ffeda3b0180025484d041 (diff)
debugger: decrease timeout used to wait for the port to be free
By default, the debugger would query the specified inspector sever port to see if it's available before starting the server, and it would keep retrying until a timeout (previously 9999 ms) is reached. This timeout seems to be longer than necessary. This patch decreases the timeout to 3 seconds. PR-URL: https://github.com/nodejs/node/pull/44359 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Richard Lau <rlau@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/debugger/inspect.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/internal/debugger/inspect.js b/lib/internal/debugger/inspect.js
index 42b5c64ab87..e006f513f9b 100644
--- a/lib/internal/debugger/inspect.js
+++ b/lib/internal/debugger/inspect.js
@@ -45,7 +45,7 @@ const debuglog = util.debuglog('inspect');
const { ERR_DEBUGGER_STARTUP_ERROR } = require('internal/errors').codes;
-async function portIsFree(host, port, timeout = 9999) {
+async function portIsFree(host, port, timeout = 3000) {
if (port === 0) return; // Binding to a random port.
const retryDelay = 150;
@@ -64,7 +64,10 @@ async function portIsFree(host, port, timeout = 9999) {
const error = await new Promise((resolve) => {
const socket = net.connect(port, host);
socket.on('error', resolve);
- socket.on('connect', resolve);
+ socket.on('connect', () => {
+ socket.end();
+ resolve();
+ });
});
if (error?.code === 'ECONNREFUSED') {
return;