From 45171c2697f2918414aca295b592e892c35a3331 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 20 Sep 2026 20:46:45 +0200 Subject: [PATCH] Bound the wait in the default test, and pin the boolean a refusal prints --- src/error-from.ts | 2 +- test/session-extras.test.ts | 11 +++-------- todo.md | 4 +++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/error-from.ts b/src/error-from.ts index 1ae1f4b..5d77236 100644 --- a/src/error-from.ts +++ b/src/error-from.ts @@ -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; } diff --git a/test/session-extras.test.ts b/test/session-extras.test.ts index d9e33ee..59522c0 100644 --- a/test/session-extras.test.ts +++ b/test/session-extras.test.ts @@ -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); diff --git a/todo.md b/todo.md index 5c119c8..108933e 100644 --- a/todo.md +++ b/todo.md @@ -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