Give up a connect after connectTimeout instead of waiting the OS out #12
+1
-1
@@ -11,7 +11,7 @@ export function errorFrom(reason: unknown): Error {
|
||||
|
||||
const printable: readonly string[] = ['boolean', 'number', 'string'];
|
||||
|
||||
/** String() throws on a null-prototype object or a symbol, so those are named by type instead. */
|
||||
/** String() throws on a null-prototype object, so anything but these is named by its type. */
|
||||
export function namedValue(value: unknown): string {
|
||||
return printable.includes(typeof value) ? String(value) : typeof value;
|
||||
}
|
||||
|
||||
@@ -1055,19 +1055,13 @@ describe('connectTimeout', () => {
|
||||
assert.equal(settled.session, undefined);
|
||||
});
|
||||
|
||||
// The fallback is what every call that names no timeout gets, and localhost settles too fast to see it.
|
||||
test('bounds a connect nobody asked to bound, at the default', async t => {
|
||||
const { accepted, port } = await stalledListener(t);
|
||||
const { port } = await stalledListener(t);
|
||||
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
|
||||
const connecting = client({ host: '127.0.0.1', port, reconnect: false, tls: true });
|
||||
|
||||
while (accepted.length === 0) {
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
}
|
||||
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
t.mock.timers.tick(10_000);
|
||||
t.mock.timers.reset();
|
||||
|
||||
@@ -1123,9 +1117,10 @@ describe('connectTimeout', () => {
|
||||
/got "5000"/,
|
||||
'an env var read without Number() is the commonest untyped value, and it is a correct number',
|
||||
);
|
||||
assert.match(checkSessionOptions({ connectTimeout: true }).err?.message ?? '', /got true/);
|
||||
assert.match(
|
||||
checkSessionOptions({ connectTimeout: 2_147_483_648 }).err?.message ?? '',
|
||||
/2147483647 ms or less/,
|
||||
/2147483647 ms or less \(about 24 days\), got 2147483648; false waits the OS out instead/,
|
||||
'a delay Node cannot hold in 32 bits fires after 1 ms, the inverse of what it asked for',
|
||||
);
|
||||
assert.equal(checkSessionOptions({ connectTimeout: 2_147_483_647 }).err, undefined);
|
||||
|
||||
@@ -192,7 +192,9 @@ the rewrite, for a dependency added later. Maintainer's call, 2026-09-14.
|
||||
of what it asked for, explained only by a warning on stderr. `connectTimeout` refuses one
|
||||
already, which is the asymmetry to close. The same four print an untyped value bare, so
|
||||
`idleTimeout: '5000'` is refused with `got 5000` — a value the reader reads as correct — where
|
||||
`connectTimeout` quotes it. Raised by review, 2026-09-20.
|
||||
`connectTimeout` quotes it. `namedValue()`'s four sites — `messagingMode`, `encoding`, the time
|
||||
options and `smsIdFormat` — are the same defect once more: there `true` and `'true'` both print
|
||||
as `true`. One fix closes all three. Raised by review, 2026-09-20.
|
||||
|
||||
- [ ] **A send the codec will refuse waits for a link and a window slot first.** `refuse()` in
|
||||
`outgoing-requests.ts` runs `misuse()` and the abort check before the wait, precisely so a call
|
||||
|
||||
Reference in New Issue
Block a user