- 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';consthttp=require('http');constport=8000;constAGENT_TIMEOUT=3000;constHTTP_TIMEOUT=5000;constserver=http.createServer((req,res)=>{console.log('never response');}).listen({ port },()=>doRequest());functiondoRequest(){constagent=newhttp.Agent({timeout: AGENT_TIMEOUT});constrequest=http.request({host: 'localhost',
port,
agent,timeout: HTTP_TIMEOUT,// The HTTP_TIMEOUT will not work.},res=>{});request.end();conststart=Date.now();request.on('timeout',()=>{console.log('timeout:'+(Date.now()-start));// It print 3000, not 5000request.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.
When request with agent, set the request timeout not work, timeout is still
agent timeout.
The code:
I expect request timeout will overwrite the agent time out.
If it's a bug, I can make a PR to fix it.