Skip to content

Commit

Permalink
Fix not calling callback
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Aug 18, 2024
1 parent 20ea410 commit 62c4d63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/rest/RequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,16 @@ export default class RequestHandler {
try {
delay = (resBody as { retry_after: number; }).retry_after * 1000;
} catch (err) {
cb();
reject(err);
}
}

this._manager.client.emit("debug", `${res.headers.has("x-ratelimit-global") ? "Global" : "Unexpected"} RateLimit: ${JSON.stringify(resBody)}\n${now} ${route} ${res.status}: ${latency}ms (${this.latencyRef.latency}ms avg) | ${this.ratelimits[route].remaining}/${this.ratelimits[route].limit} left | Reset ${delay} (${this.ratelimits[route].reset - now}ms left) | Scope ${res.headers.get("x-ratelimit-scope")!}`);
if (delay) {
if (delay > this.options.maxRatelimitRetryWindow) {
reject(new RateLimitedError(`Ratelimit on "${options.method} ${route}" exceeds the maximum retry window (${delay} > ${this.options.maxRatelimitRetryWindow})`));
cb();
return reject(new RateLimitedError(`Ratelimit on "${options.method} ${route}" exceeds the maximum retry window (${delay} > ${this.options.maxRatelimitRetryWindow})`));
}
setTimeout(() => {
cb();
Expand Down
2 changes: 1 addition & 1 deletion lib/types/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface RESTOptions {
*/
latencyThreshold?: number;
/**
* In milliseconds, the maximum ratelimit delay (in seconds) the lib will internally wait for to retry the request. If a ratelimit resets after this window, an error will be thrown instead.
* In milliseconds, the maximum ratelimit delay (in milliseconds) the lib will internally wait for to retry the request. If a ratelimit resets after this window, an error will be thrown instead.
* @note This currently defaults to Infinity for backwards compatibility, but this will be changed in 1.12.0.
* @defaultValue Infinity
*/
Expand Down

0 comments on commit 62c4d63

Please sign in to comment.