Skip to content

Commit ef4a481

Browse files
authored
Fixed infinite retry loop on repeated 429 rate limit responses (#651)
1 parent 7220e8c commit ef4a481

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/rest/sequentialBucket.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ export class SequentialBucket {
179179
if (res.status >= 400 && res.status < 500) {
180180
const data: any = await parseResponse(res);
181181
if (res.status === 429) {
182+
if (attempts >= this.#handler.options.retryLimit!)
183+
throw new DiscordRESTError(request, res, data, stackHolder.stack);
184+
182185
const delay = data?.retry_after ? data.retry_after * 1000 : retryAfter;
183186
this.#handler.creator?.emit(
184187
'debug',
@@ -187,7 +190,7 @@ export class SequentialBucket {
187190

188191
if (delay) await Mutex.wait(delay);
189192

190-
return this.#execute(request, attempts);
193+
return this.#execute(request, ++attempts);
191194
}
192195

193196
throw new DiscordRESTError(request, res, data, stackHolder.stack);

0 commit comments

Comments
 (0)