Is there a option that i reset default timeout for request
cmingxu opened this issue · 4 comments
cmingxu commented
I want a place to set timeout for requests, node default timeout kind of too long for my scenario.
ejfinneran commented
@cmingxu I was just looking for the same functionality. I'm playing around with how best to implement this. Can you take a look at my fork and see if you would do things differently?
My fork currently works this way:
- You call the timeout method and pass the number of milliseconds you want to wait.
- If the timeout is reach before the request is completed, req.abort() is called
- The standard callback is triggered with err set to
ECONNRESET
and resp/body set to null.
Thoughts?
https://github.com/ejfinneran/node-scoped-http-client/tree/timeout-support
client = ScopedClient.create('http://10.255.255.1:9999');
client.timeout(100);
client.get()(function(err, resp, body) {
if (err) {
util.puts("ERROR: " + err);
}
});
drdamour commented
@ejfinneran +1 for your solution's syntax, but your fork seems to be missing
ejfinneran commented
@drdamour Whoops! I had done some repo house cleaning and forgot I had that branch but I just restored it.
pseudomuto commented
Anyone still looking at this?