feat: add ClientOptions#retryLimit (#2805)

* feat: add ClientOptions#retryLimit

* hydra needs to learn how to code right

* a default would probably help

* move incrementor & update comment

* clarify docs on Infinity
This commit is contained in:
Isabella
2018-08-31 21:51:35 -05:00
committed by Crawl
parent 3970c5005b
commit be4d6f9dc3
5 changed files with 10 additions and 3 deletions

View File

@@ -150,13 +150,13 @@ class RequestHandler {
await Util.delayFor(this.retryAfter);
return this.run();
} else if (res.status >= 500 && res.status < 600) {
// Retry once for possible serverside issues
if (item.retried) {
// Retry the specified number of times for possible serverside issues
if (item.retries === this.manager.client.options.retryLimit) {
return reject(
new HTTPError(res.statusText, res.constructor.name, res.status, item.request.method, request.route)
);
} else {
item.retried = true;
item.retries++;
this.queue.unshift(item);
return this.run();
}