mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user