mirror of
https://github.com/danbulant/discord.js
synced 2026-06-06 08:11:50 +00:00
fix(RequestHandler): only retry once on 5xx (#2471)
This commit is contained in:
parent
56a9d1ba3c
commit
14aab1be38
1 changed files with 8 additions and 2 deletions
|
|
@ -80,8 +80,14 @@ class RequestHandler {
|
||||||
this.queue.unshift(item);
|
this.queue.unshift(item);
|
||||||
finish(Number(res.headers['retry-after']) + this.client.options.restTimeOffset);
|
finish(Number(res.headers['retry-after']) + this.client.options.restTimeOffset);
|
||||||
} else if (err.status >= 500 && err.status < 600) {
|
} else if (err.status >= 500 && err.status < 600) {
|
||||||
this.queue.unshift(item);
|
if (item.retried) {
|
||||||
finish(1e3 + this.client.options.restTimeOffset);
|
item.reject(err);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
item.retried = true;
|
||||||
|
this.queue.unshift(item);
|
||||||
|
finish(1e3 + this.client.options.restTimeOffset);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
item.reject(err.status >= 400 && err.status < 500 ?
|
item.reject(err.status >= 400 && err.status < 500 ?
|
||||||
new DiscordAPIError(res.request.path, res.body, res.request.method) : err);
|
new DiscordAPIError(res.request.path, res.body, res.request.method) : err);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue