node-request-retry
node-request-retry copied to clipboard
Custom retry strategy not retrying in certain cases
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: https://github.com/FGRibreau/node-request-retry/blob/e72edee56296b7163d18e061975c139f4caf1ff0/index.js#L133-L146
Good catch, I will accept a PR with a non regression test :+1: