You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
http.IncomingMessage.setTimeout callback will never be called? #13864
Platform: Darwin XXXXX.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64 (Mac OS 10.12.5, installed with HomeBrew 1.2.3)
Subsystem: http
The documentation tells us that http.IncomingMessage.setTimeout(msecs, callback) calls message.connection.setTimeout(msecs, callback). However, by looking at the code, it seems that it indeed calls message.connection.setTimeout(msecs) (through the socket object) but callback gets attached as a listener of the timeout event coming from the IncomingMessage class.
First of all, please correct me if I'm wrong, but this behavior is not quite what the documentation describes is it?
Then, despite the fact that the timeout event apparently gets fired there, for some reason, I can't get callback in http.IncomingMessage.setTimeout(msec, callback) to be called.
I believe this is because, in your example, the request is not actually timing out. You're just sending a simple GET request with curl that doesn't hang around and take more than 500ms. If you change your server.listen() callback to something like this, you'll see that the req.setTimeout function is called.
server.listen(1234,()=>{console.log('Listening');constreq=http.request({port: 1234,method: 'POST',path: '/long'});req.write('This could take a while...');setTimeout(_=>{req.end('See? I told you');},1000);});
Activity
lance commentedon Jun 22, 2017
I believe this is because, in your example, the request is not actually timing out. You're just sending a simple
GETrequest withcurlthat doesn't hang around and take more than 500ms. If you change yourserver.listen()callback to something like this, you'll see that thereq.setTimeoutfunction is called.lance commentedon Jun 22, 2017
Closing for now. @nodejs/collaborators feel free to reopen if I am mistaken.
stouf commentedon Jun 23, 2017
Thanks @lance , I was indeed misunderstand pending requests on the server-side and client request timing out. Thanks for the explanation! :)
Pin backend master c36bdc0 (memory stack nodejs#13864 nodejs#13849 no…