Skip to content

Commit 5aa3100

Browse files
Trotttargos
authored andcommitted
test: fix flaky http timeout test
There is no guarantee that a timeout won't be delayed considerably due to unrelated activity on the host. Instead of checking that the timeout happens within a certain tolerance, simply check that it did not happen too soon. Fixes: #22041 PR-URL: #22403 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 33994d8 commit 5aa3100

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/sequential/test-http-client-timeout-option-with-agent.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ function doRequest() {
4242
timeout_events += 1;
4343
const duration = Date.now() - start;
4444
// The timeout event cannot be precisely timed. It will delay
45-
// some number of milliseconds, so test it in second units.
46-
assert.strictEqual(duration / 1000 | 0, HTTP_CLIENT_TIMEOUT / 1000);
45+
// some number of milliseconds.
46+
assert.ok(duration >= HTTP_CLIENT_TIMEOUT,
47+
`${duration} < ${HTTP_CLIENT_TIMEOUT}`);
4748
}));
4849
req.end();
4950

0 commit comments

Comments
 (0)