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 was h…
Browse files Browse the repository at this point in the history
…it (#78)

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
  • Loading branch information
ckohen and SpaceEEC committed Dec 8, 2021
1 parent c3aba56 commit a4e404b
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 @@ -397,15 +397,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 @@ -429,6 +420,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 a4e404b

Please sign in to comment.