Skip to content

Commit

Permalink
fix(RequestHandler): only retry once on 5xx (#2471)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEEC authored May 25, 2018
1 parent 56a9d1b commit 14aab1b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/rest/handlers/RequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ class RequestHandler {
this.queue.unshift(item);
finish(Number(res.headers['retry-after']) + this.client.options.restTimeOffset);
} else if (err.status >= 500 && err.status < 600) {
this.queue.unshift(item);
finish(1e3 + this.client.options.restTimeOffset);
if (item.retried) {
item.reject(err);
finish();
} else {
item.retried = true;
this.queue.unshift(item);
finish(1e3 + this.client.options.restTimeOffset);
}
} else {
item.reject(err.status >= 400 && err.status < 500 ?
new DiscordAPIError(res.request.path, res.body, res.request.method) : err);
Expand Down

0 comments on commit 14aab1b

Please sign in to comment.