feat(rest): unref queue timers to prevent process hang (#4693)

Currently if a queue is pending deletion or waiting to refill its ratelimit will keep the process alive, this is not ideal for scripts like command deployment ones
This does not impact the functionality of the queues in any way, just allows the process to exit if nothing else is pending in which case you would be loosing the ratelimit information anyway
This commit is contained in:
Fleny
2026-01-20 07:30:21 +01:00
committed by GitHub
parent 8652941544
commit 6a5c346546

View File

@@ -1,3 +1,4 @@
import { setTimeout } from 'node:timers';
import { delay } from '@discordeno/utils';
import type { RestManager, SendRequestOptions } from './types.js';
@@ -126,7 +127,7 @@ export class Queue {
this.timeoutId ??= setTimeout(() => {
this.remaining = this.max;
this.timeoutId = undefined;
}, this.interval);
}, this.interval).unref();
}
// Remove from queue, we are executing it.
@@ -162,7 +163,7 @@ export class Queue {
this.timeoutId ??= setTimeout(() => {
this.remaining = this.max;
this.timeoutId = undefined;
}, headers.interval);
}, headers.interval).unref();
}
}
@@ -201,7 +202,7 @@ export class Queue {
`[Queue] ${this.queueType} ${this.url}. Deleted! Remaining: (${this.rest.queues.size})`,
[...this.rest.queues.values()].map((queue) => `${queue.queueType}${queue.url}`),
);
}, this.deleteQueueDelay);
}, this.deleteQueueDelay).unref();
}
/** Simply checks if the queue is able to be cleared or it has requests pending. */