Skip to content

Commit

Permalink
fix: make ratelimit timeout require event loop to be active (#8779)
Browse files Browse the repository at this point in the history
* fix issue with ratelimits not working correctly

related to #8757

The ``ref`` option doesn't require the Node.js event loop to remain active when waiting for the timeout causing the program to end if there isn't an active gateway connection.

* Update packages/rest/src/lib/handlers/SequentialHandler.ts

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* Update packages/rest/src/lib/handlers/SequentialHandler.ts

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
  • Loading branch information
hackermondev and Jiralite committed Oct 23, 2022
1 parent b2658ce commit 68d5712
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/rest/src/lib/handlers/SequentialHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class SequentialHandler implements IHandler {
* @param time - The amount of time to delay all requests for
*/
private async globalDelayFor(time: number): Promise<void> {
await sleep(time, undefined, { ref: false });
await sleep(time);
this.manager.globalDelay = null;
}

Expand Down Expand Up @@ -460,7 +460,7 @@ export class SequentialHandler implements IHandler {

this.#sublimitPromise?.resolve();
this.#sublimitPromise = null;
await sleep(sublimitTimeout, undefined, { ref: false });
await sleep(sublimitTimeout);
let resolve: () => void;
// eslint-disable-next-line promise/param-names, no-promise-executor-return
const promise = new Promise<void>((res) => (resolve = res));
Expand Down

0 comments on commit 68d5712

Please sign in to comment.