no effect from timeout
drewp opened this issue · comments
node v0.8.8, shred 0.8.3
shred.get({
url: url,
headers: headers,
timeout: 2000,
on: {
error: function (response) {
log.info("error cb", response);
}
}
});
I have yet to see that log line print, and instead I get neverending hangs. #28 seems like it was trying to fix and test the timeout system.
Thanks for the report. I've been working on a possibly related problem with timeouts and noted the lack of effective testing in this area.
The related issue was #38.
It looks like a usage problem (which really means a documentation problem). The "on" field must contain a handler for "timeout", because that is considered a different kind of event than "error". There's an example in the tests: https://github.com/automatthew/shred/blob/master/test/shred.js#L434-449
There are three error-like events you might want to handle:
- error: HTTP responses with statuses >= 400
- request_error: connection errors
- timeout: client-specified, voluntary timeout.
Socket timeouts (as I just discovered) become "request_error" events.