Give up a connect after connectTimeout instead of waiting the OS out #12

Merged
lilleman merged 7 commits from connect-timeout into main 2026-09-20 20:58:14 +02:00
Showing only changes of commit 92fbd6a9f2 - Show all commits
+3 -9
View File
@@ -1055,17 +1055,11 @@ describe('connectTimeout', () => {
assert.equal(settled.session, undefined); assert.equal(settled.session, undefined);
}); });
test('bounds a connect nobody asked to bound, at the default', async t => { // Waits the default out for real: node:test mock timers land in Node 20.4, and the floor is 18.
test('bounds a connect nobody asked to bound, at the default ten seconds', async t => {
const { 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 }); const connecting = client({ host: '127.0.0.1', port, reconnect: false, tls: true });
const settled = await within(13_000, connecting);
t.mock.timers.tick(10_000);
t.mock.timers.reset();
const settled = await within(2000, connecting);
assert.ok(settled, 'no bound was armed, so nothing ever settled this connect'); assert.ok(settled, 'no bound was armed, so nothing ever settled this connect');
assert.ok(settled.err instanceof Error); assert.ok(settled.err instanceof Error);