Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor test-http-client-timeout-option-with-agent #25752

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/parallel/test-http-client-timeout-option-with-agent.js
Expand Up @@ -30,8 +30,8 @@ server.listen(0, options.host, () => {

function doRequest() {
options.port = server.address().port;
const start = process.hrtime.bigint();
const req = http.request(options);
const start = Date.now();
req.on('error', () => {
// This space is intentionally left blank.
});
Expand All @@ -40,11 +40,11 @@ function doRequest() {
let timeout_events = 0;
req.on('timeout', common.mustCall(() => {
timeout_events += 1;
const duration = Date.now() - start;
const duration = process.hrtime.bigint() - start;
// The timeout event cannot be precisely timed. It will delay
// some number of milliseconds.
assert.ok(
duration >= HTTP_CLIENT_TIMEOUT,
duration >= BigInt(HTTP_CLIENT_TIMEOUT * 1e6),
`duration ${duration}ms less than timeout ${HTTP_CLIENT_TIMEOUT}ms`
);
}));
Expand Down