-
-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Labels
Description
Following the custom retry strategy example below (from the readme):
/**
* @param {Null | Object} err
* @param {Object} response
* @param {Object} body
* @param {Object} options copy
* @return {Boolean} true if the request should be retried
*/
function myRetryStrategy(err, response, body, options){
// retry the request if we had an error or if the response was a 'Bad Gateway'
return err || response.statusCode === 502;
}When err is an object and this function returns that object, mustRetry becomes undefined bypassing the desired retry attempt based on the logic here because mustRetry.mustRetry is not a thing in this scenario:
Lines 133 to 146 in e72edee
| var mustRetry = this.retryStrategy(err, response, body, _.cloneDeep(this.options)); | |
| if (_.isObject(mustRetry)) { | |
| if (_.isObject(mustRetry.options)) { | |
| this.options = mustRetry.options; //if retryStrategy supposes different request options for retry | |
| } | |
| mustRetry = mustRetry.mustRetry; | |
| } | |
| if (mustRetry && this.maxAttempts > 0) { | |
| this._timeout = setTimeout(this._tryUntilFail.bind(this), this.delayStrategy.call(this, err, response, body)); | |
| return; | |
| } | |
| this.reply(err, response, body); |
BradLook