-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.
Description
- Version: 10.3
- Platform: all
- Subsystem: http
When request with agent, set the request timeout not work, timeout is still
agent timeout.
The code:
'use strict';
const http = require('http');
const port = 8000;
const AGENT_TIMEOUT = 3000;
const HTTP_TIMEOUT = 5000;
const server = http
.createServer((req, res) => {
console.log('never response');
})
.listen({ port }, () => doRequest());
function doRequest() {
const agent = new http.Agent({ timeout: AGENT_TIMEOUT });
const request = http.request({
host: 'localhost',
port,
agent,
timeout: HTTP_TIMEOUT, // The HTTP_TIMEOUT will not work.
}, res => {});
request.end();
const start = Date.now();
request.on('timeout', () => {
console.log('timeout:' + (Date.now() - start)); // It print 3000, not 5000
request.abort();
server.close();
});
request.on('error', () => {});
}
I expect request timeout will overwrite the agent time out.
If it's a bug, I can make a PR to fix it.
Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.