example in docs
kof opened this issue · 1 comments
kof commented
I think you should fix the example in the readme.
function faultTolerantResolve(address, cb) {
var operation = retry.operation();
operation.attempt(function(currentAttempt) {
dns.resolve(address, function(err, addresses) {
if (operation.retry(err)) {
return;
}
cb(operation.mainError(), addresses);
});
});
}
The issue is here:
cb(operation.mainError(), addresses);
Once an error was passed, mainError will always return an error, however an error needs only to be passed to the callback if retries did not help.
cb(err ? operation.mainError() : null, addresses);
Best,
Oleg
tim-kos commented
Thanks Oleg, you are right.
Closing this.