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

feat(SequentialHandler): add more info to debug when rate limit was hit #78

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(
iCrawl marked this conversation as resolved.
Show resolved Hide resolved
[
'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