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
+6 -7
View File
@@ -168,20 +168,19 @@ function limitsOf(options: CheckableOptions): [string, number, number][] {
];
}
/** Node's timers are 32-bit, and a delay above this one fires after 1 ms instead of never. */
const maxTimerDelay = 2_147_483_647;
function checkConnectTimeout(connectTimeout: number | undefined): VoidResult {
function checkConnectTimeout(connectTimeout: unknown): VoidResult {
if (connectTimeout === undefined) return {};
const got = String(connectTimeout);
const got = typeof connectTimeout === 'string' ? `"${connectTimeout}"` : namedValue(connectTimeout);
if (!Number.isInteger(connectTimeout) || connectTimeout < 1) {
return { err: new Error(`connectTimeout must be a whole number of milliseconds, 1 or more, got ${got}; omit it to wait the OS out`) };
if (typeof connectTimeout !== 'number' || !Number.isInteger(connectTimeout) || connectTimeout < 1) {
return { err: new Error(`connectTimeout must be a whole number of milliseconds, 1 or more, got ${got}; omit it or pass undefined to wait the OS out`) };
}
if (connectTimeout > maxTimerDelay) {
return { err: new Error(`connectTimeout must be ${String(maxTimerDelay)} or less, got ${got}`) };
return { err: new Error(`connectTimeout must be ${String(maxTimerDelay)} ms or less (about 24 days), got ${got}`) };
}
return {};
@@ -265,7 +264,7 @@ function checkSmsIdFormat(smsIdFormat: unknown): VoidResult {
/** What the checker reads, as it arrives: a caller without types can put anything in it. */
export type CheckableOptions = {
connectTimeout?: number | undefined;
connectTimeout?: unknown;
/** Not an option: the one spelling is inside reconnect, and this is where the other is refused. */
fromStart?: unknown;
idleTimeout?: number | undefined;