From 68d5712deae85532604d93b4505f0953d664cde7 Mon Sep 17 00:00:00 2001 From: hackermon Date: Sun, 23 Oct 2022 06:45:02 -0400 Subject: [PATCH] fix: make ratelimit timeout require event loop to be active (#8779) * 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> --- packages/rest/src/lib/handlers/SequentialHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rest/src/lib/handlers/SequentialHandler.ts b/packages/rest/src/lib/handlers/SequentialHandler.ts index 60ca20851..c28ec445d 100644 --- a/packages/rest/src/lib/handlers/SequentialHandler.ts +++ b/packages/rest/src/lib/handlers/SequentialHandler.ts @@ -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 { - await sleep(time, undefined, { ref: false }); + await sleep(time); this.manager.globalDelay = null; } @@ -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((res) => (resolve = res));