Name the peer and the stalled phase on a connect timeout, and quote an untyped value
Mirror / push (push) Successful in 5s
Test / lint (pull_request) Successful in 21s
Test / test (18) (pull_request) Successful in 19s
Test / test (20) (pull_request) Successful in 19s
Test / test (22) (pull_request) Successful in 24s
Test / test (24) (pull_request) Successful in 18s
Test / test (26) (pull_request) Successful in 19s

This commit is contained in:
2026-09-20 18:17:39 +02:00
parent 84174b4a5b
commit 8f416c2bc4
8 changed files with 48 additions and 21 deletions
+8 -3
View File
@@ -56,14 +56,19 @@ const defaults = {
function armConnectTimeout(
sock: Socket,
connectTimeout: number | undefined,
peer: string,
settle: (result: Result<{ sock: Socket }>) => void,
): NodeJS.Timeout | undefined {
if (connectTimeout === undefined) return undefined;
// The connecting socket is what holds the process, so this wait never has to.
// A firewall and a stalled handshake need different answers, and only the phase tells them apart.
let phase = `connecting to ${peer}`;
sock.once('connect', () => { phase = `completing the TLS handshake with ${peer}`; });
return setTimeout(() => {
sock.destroy();
settle({ err: new Error(`Timed out connecting after ${String(connectTimeout)} ms`) });
settle({ err: new Error(`Timed out ${phase} after ${String(connectTimeout)} ms`) });
}, connectTimeout).unref();
}
@@ -115,7 +120,7 @@ function openSocket(options: ClientOptions): Promise<Result<{ sock: Socket }>> {
settle({ sock });
});
const timer = armConnectTimeout(sock, connectTimeout, settle);
const timer = armConnectTimeout(sock, connectTimeout, `${host}:${String(port)}`, settle);
});
}