make sure QueueModule.dispose always completes

This commit is contained in:
Hazelnoot 2025-09-27 19:59:22 -04:00
parent 910af0532c
commit 89981285b2

View file

@ -10,6 +10,8 @@ import type { Config } from '@/config.js';
import { baseQueueOptions, QUEUE } from '@/queue/const.js';
import { allSettled } from '@/misc/promise-tracker.js';
import Logger from '@/logger.js';
import { bindThis } from '@/decorators.js';
import { renderInlineError } from '@/misc/render-inline-error.js';
import {
DeliverJobData,
EndedPollNotificationJobData,
@ -142,7 +144,7 @@ export class QueueModule implements OnApplicationShutdown {
await allSettled();
// And then close all queues
this.logger.info('Closing BullMQ queues...');
await Promise.all([
await Promise.allSettled([
this.systemQueue.close(),
this.endedPollNotificationQueue.close(),
this.deliverQueue.close(),
@ -153,7 +155,13 @@ export class QueueModule implements OnApplicationShutdown {
this.userWebhookDeliverQueue.close(),
this.systemWebhookDeliverQueue.close(),
this.scheduleNotePostQueue.close(),
]);
]).then(res => {
for (const result of res) {
if (result.status === 'rejected') {
this.logger.error(`Error closing queue: ${renderInlineError(result.reason)}`);
}
}
});
this.logger.info('Queue module disposed.');
}