-
Notifications
You must be signed in to change notification settings - Fork 236
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
open timeout not cleared until read response #229
Comments
I'll take a look in a minute. Thanks for reporting! |
You're right, open timeout should be cleared when the connection is established, rather than when the response headers are received. This is simply the result of Needle using the available events provided by Node's HTTP module. There is, actually, a 'connect' event but it serves a totally different purpose. It simply fires whenever a server responds to a CONNECT type request. Now it looks like the underlying net module does provide a real 'connect' event so I think we might be able to pull it off. I'll dive into this later tonight. Thanks again for the heads up. |
I think this should do it: What do you think? |
hi @tomas echo test: this change establishes a cascade of timers:
i think this looks good. it is also analogous to the accepted solution here: https://stackoverflow.com/a/9910413 that SO solution has one extra bit, i'm not sure if it's necessary, but it might be worth some reflection:
i believe that this |
No, we don't need to listen for 'timeout' events since we use the regular setTimeout instead of socket.setTimeout, which doesn't work consistently across different node.js versions. I'm also thinking of adding a 'max_time' option, which would act as a global timer for the whole request/response process, although I'm not sure what the behaviour should be when following redirects. Any ideas? |
i suggest we move the max_time discussion to a separate PR. it seems like a nice feature to have. |
Ok, just published v2.1.0 with the updated behaviour. Thanks again! |
if i make a blocking request to a service that takes more than 10 seconds, needle will fail, in its default configuration, due to the default open timeout of 10 seconds.
it appears that the open timeout is not cleared until a read response is received. https://github.com/tomas/needle/blob/master/lib/needle.js#L479
my interpretation of "open timeout" is as relates to the time until a socket connection is established. this helps one distinguish network partitions or edge failures from service outages.
The text was updated successfully, but these errors were encountered: