Skip to content

Commit b1eafe1

Browse files
joyeecheungRafaelGSS
authored andcommitted
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: #44359 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent 8175c65 commit b1eafe1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/internal/debugger/inspect.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const debuglog = util.debuglog('inspect');
4545

4646
const { ERR_DEBUGGER_STARTUP_ERROR } = require('internal/errors').codes;
4747

48-
async function portIsFree(host, port, timeout = 9999) {
48+
async function portIsFree(host, port, timeout = 3000) {
4949
if (port === 0) return; // Binding to a random port.
5050

5151
const retryDelay = 150;
@@ -64,7 +64,10 @@ async function portIsFree(host, port, timeout = 9999) {
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;

test/common/debugger.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ const BREAK_MESSAGE = new RegExp('(?:' + [
77
'exception', 'other', 'promiseRejection',
88
].join('|') + ') in', 'i');
99

10-
const TIMEOUT = common.platformTimeout(5000);
10+
let TIMEOUT = common.platformTimeout(5000);
11+
if (common.isWindows) {
12+
// Some of the windows machines in the CI need more time to receive
13+
// the outputs from the client.
14+
// https://github.com/nodejs/build/issues/3014
15+
TIMEOUT = common.platformTimeout(15000);
16+
}
1117

1218
function isPreBreak(output) {
1319
return /Break on start/.test(output) && /1 \(function \(exports/.test(output);

0 commit comments

Comments
 (0)