-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
I'm working with an api where sometimes the res.statusCode for a request is 503 but the err.code isn't. This means call.retryIf is never called because err is undefined.
My attempted remedy:
const reqRetryCodes = {
'ECONNRESET': true,
'ETIMEDOUT': true,
'ENOTFOUND': true,
503: true
}
const _tryRequest = backoff.call(
request,
{
url: myUrl,
json: true
},
(err,res,body) => {
if(err){
if(reqRetryCodes[err.code]===true){
_tryRequest.backoff(); //retry backoff
return;
}
reject(err);
return;
}
if(reqRetryCodes[res.statusCode]===true){
_tryRequest.backoff(); //retry backoff
return;
}
resolve(body);
}
);
_tryRequest.setStrategy(new backoff.ExponentialStrategy());
_tryRequest.start();Gives:
TypeError: _tryRequest.backoff is not a function
Metadata
Metadata
Assignees
Labels
No labels