Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
feat(SequentialHandler): add more info to debug when rate limit wa shit
Browse files Browse the repository at this point in the history
Ported from discordjs/discord.js#5801

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
  • Loading branch information
ckohen and SpaceEEC committed Dec 2, 2021
1 parent c190f00 commit 84c39a9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/rest/src/lib/handlers/SequentialHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,6 @@ export class SequentialHandler {
return parseResponse(res);
} else if (res.status === 429) {
// A rate limit was hit - this may happen if the route isn't associated with an official bucket hash yet, or when first globally rate limited
this.debug(
[
'Encountered unexpected 429 rate limit',
` Bucket : ${routeId.bucketRoute}`,
` Major parameter: ${routeId.majorParameter}`,
` Hash : ${this.hash}`,
` Retry After : ${retryAfter}ms`,
].join('\n'),
);
const isGlobal = this.globalLimited;
let limit: number;
let timeout: number;
Expand All @@ -402,6 +393,20 @@ export class SequentialHandler {
majorParameter: this.majorParameter,
global: isGlobal,
});
this.debug(
[
'Encountered unexpected 429 rate limit',
` Global : ${isGlobal.toString()}`,
` Method : ${method}`,
` URL : ${url}`,
` Bucket : ${routeId.bucketRoute}`,
` Major parameter: ${routeId.majorParameter}`,
` Hash : ${this.hash}`,
` Limit : ${limit}`,
` Retry After : ${retryAfter}ms`,
` Sublimit : ${sublimitTimeout ? `${sublimitTimeout}ms` : 'None'}`,
].join('\n'),
);
// If caused by a sublimit, wait it out here so other requests on the route can be handled
if (sublimitTimeout) {
// Normally the sublimit queue will not exist, however, if a sublimit is hit while in the sublimit queue, it will
Expand Down

0 comments on commit 84c39a9

Please sign in to comment.