-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Consistent failure of test-http-client-timeout-option-with-agent #25746
Comments
Do you see the failure when you run |
Seems to me like maybe |
@Trott it goes from 2993ms to 2998ms, so definitely closer, but still not passing. |
What happens with this one (which also switches to 'use strict';
const common = require('../common');
// Test that when http request uses both timeout and agent,
// timeout will work as expected.
const assert = require('assert');
const http = require('http');
const HTTP_AGENT_TIMEOUT = 1000;
const HTTP_CLIENT_TIMEOUT = 3000;
const agent = new http.Agent({ timeout: HTTP_AGENT_TIMEOUT });
const options = {
method: 'GET',
port: undefined,
host: '127.0.0.1',
path: '/',
timeout: HTTP_CLIENT_TIMEOUT,
agent,
};
const server = http.createServer(() => {
// Never respond.
});
server.listen(0, options.host, () => {
doRequest();
});
function doRequest() {
options.port = server.address().port;
const start = process.hrtime.bigint();
const req = http.request(options);
req.on('error', () => {
// This space is intentionally left blank.
});
req.on('close', common.mustCall(() => server.close()));
let timeout_events = 0;
req.on('timeout', common.mustCall(() => {
timeout_events += 1;
const duration = process.hrtime.bigint() - start;
// The timeout event cannot be precisely timed. It will delay
// some number of milliseconds.
assert.ok(
duration >= BigInt(HTTP_CLIENT_TIMEOUT * 1e6),
`duration ${duration}ms less than timeout ${HTTP_CLIENT_TIMEOUT}ms`
);
}));
req.end();
setTimeout(() => {
req.destroy();
assert.strictEqual(timeout_events, 1);
// Ensure the `timeout` event fired only once.
}, common.platformTimeout(HTTP_CLIENT_TIMEOUT * 2));
} I'll be mildly surprised if that actually fixes it for you, but if so, hey, great. |
Another thing to try might be to see if the test passes if you set the agent timeout constant to 3000 instead of 1000. If the test starts passing then, that suggests that this may be a legitimate bug and not a problem with the test. |
@Trott it passes with bigint, but it also passes when i change it to 1000ms |
@nodejs/http |
@devsnek What OS are you running? |
I think switching to |
@Trott macos 10.14.3 |
* Switch from Date.now() to process.hrtime.bigint(). * Move start time recording to before the request is created, not after. Fixes: nodejs#25746
That's Mojave, right? You didn't update very recently, did you? |
PR to fix: #25752 |
* Switch from Date.now() to process.hrtime.bigint(). * Move start time recording to before the request is created, not after. Fixes: nodejs#25746 PR-URL: nodejs#25752 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]>
Fixed in b897704 |
* Switch from Date.now() to process.hrtime.bigint(). * Move start time recording to before the request is created, not after. Fixes: #25746 PR-URL: #25752 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]>
Every time I run the suite I see this failure:
cc @Trott who messed with the timers in this test last
The text was updated successfully, but these errors were encountered: