From 4c7bbd418254ad7b9fceffad59ca976ef93cbc87 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sat, 5 Sep 2026 17:49:59 +0000 Subject: [PATCH] test: widen the gap in the resolver maxTimeout comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test-dns-resolver-max-timeout times a query with `{ timeout: 500, tries: 3 }` against one that also sets `maxTimeout: 500` and asserts the first took longer. c-ares only expires a try when cares_wrap's timer fires, every `timeout` ms, so each try costs one or two ticks depending on sub-millisecond ordering, and uncapped retries also get 0.5-1x jitter. That leaves the capped run anywhere in 1500-3000 ms and the uncapped one in 3000-4500 ms; on a busy rhel10-ppc64le host both came out at 3005 ms. With `timeout: 100, tries: 5` the ranges (about 600-1000 ms and 5000-7500 ms measured under load) cannot meet. Signed-off-by: Shelley Vohr PR-URL: https://github.com/nodejs/node/pull/65780 Fixes: https://github.com/nodejs/node/issues/64226 Refs: https://github.com/nodejs/node/issues/59146 Refs: https://github.com/nodejs/node/issues/54534 Reviewed-By: Filip Skokan Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Gürgün Dayıoğlu Reviewed-By: Moshe Atlow --- test/parallel/test-dns-resolver-max-timeout.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-dns-resolver-max-timeout.js b/test/parallel/test-dns-resolver-max-timeout.js index 7abac39323e..1a4aaef96c9 100644 --- a/test/parallel/test-dns-resolver-max-timeout.js +++ b/test/parallel/test-dns-resolver-max-timeout.js @@ -52,9 +52,11 @@ server.bind(0, common.mustCall(async () => { // Test that maxTimeout is effective. // Without maxTimeout, the timeout will keep increasing when retrying. - const timeout1 = await timeout(address, { timeout: 500, tries: 3 }); - // With maxTimeout, the timeout will always be 500 when retrying. - const timeout2 = await timeout(address, { timeout: 500, tries: 3, maxTimeout: 500 }); + // Expired tries are only noticed on the resolver's `timeout` ms timer tick, + // so use enough tries that the doubling run cannot overlap the capped one. + const timeout1 = await timeout(address, { timeout: 100, tries: 5 }); + // With maxTimeout, the timeout will always be 100 when retrying. + const timeout2 = await timeout(address, { timeout: 100, tries: 5, maxTimeout: 100 }); console.log(`timeout1: ${timeout1}, timeout2: ${timeout2}`); assert.strictEqual(timeout1 !== undefined && timeout2 !== undefined, true); assert.strictEqual(timeout1 > timeout2, true);