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
request.setTimeout should be used for inactivity #181
Comments
Super, that's very helpful. The current timeout semantics are indeed not the ones you mention; I wonder if you have an official source for this desired behavior? The Node.js documentation is vague on it. |
request.setTimeout refers to socket.setTimeout, which says, emphasis mine:
You can also simply change my sample code about to use native |
request.setTimeout
incorrectly clears on response
follow-redirects/index.js
Line 207 in 6f5029a
In the standard
http
module,ClientRequest.setTimeout()
is passed down tonet.Socket.setTimeout()
, which fires thetimeout
event if the socket is idle long enough.timeout
could fire if the server doesn't respond fast enough, but could also fire for a multi-part response with a big delay between data packets.setTimeout
does not look at the whole request lifecycle from start to finish (i.e. you could have a timeout of 1000ms with a server sending data every 900ms — the entire request could take > 1000ms, but since the socket is still receiving data < 1000ms between packets,timeout
will not fire).If the goal is to mimic
http
's API, we need to continue monitoring for a timeout, even after the very first response.To reproduce:
Maybe a fix would pass the timeout down to each underlying
socket
in the redirect chain and emitRedirectableRequest
'stimeout
event if any underlying socket emitted?The text was updated successfully, but these errors were encountered: