Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
Do not use cloned agent
  • Loading branch information
emmansun committed Nov 4, 2020
1 parent a6e72dd commit 8c85f72
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Expand Up @@ -130,10 +130,12 @@ Request.prototype._tryUntilFail = function () {
err.attempts = this.attempts;
}

const originalAgent = this.options.agent;
var mustRetry = await Promise.resolve(this.retryStrategy(err, response, body, _.cloneDeep(this.options)));
if (_.isObject(mustRetry) && _.has(mustRetry, 'mustRetry')) {
if (_.isObject(mustRetry.options)) {
this.options = mustRetry.options; //if retryStrategy supposes different request options for retry
this.options.agent = originalAgent;
}
mustRetry = mustRetry.mustRetry;
}
Expand Down

0 comments on commit 8c85f72

Please sign in to comment.