mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-21 02:40:08 +00:00
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:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user