Add logs to worker job handling (#14171)

I'm troubleshooting queue worker getting stuck on production and I
suspect a particular job to be the root cause. However I can pinpoint
which one it is. Adding this logs will be helpful to troubleshoot
This commit is contained in:
Charles Bochet
2025-08-30 14:08:30 +02:00
committed by GitHub
parent dfa73e9e7a
commit cef476cd76
@@ -1,4 +1,4 @@
import { type OnModuleDestroy } from '@nestjs/common';
import { Logger, type OnModuleDestroy } from '@nestjs/common';
import {
type JobsOptions,
@@ -26,6 +26,7 @@ export type BullMQDriverOptions = QueueOptions;
const V4_LENGTH = 36;
export class BullMQDriver implements MessageQueueDriver, OnModuleDestroy {
private logger = new Logger(BullMQDriver.name);
private queueMap: Record<MessageQueue, Queue> = {} as Record<
MessageQueue,
Queue
@@ -71,7 +72,13 @@ export class BullMQDriver implements MessageQueueDriver, OnModuleDestroy {
queueName,
async (job) => {
// TODO: Correctly support for job.id
this.logger.log(
`Processing job ${job.id} with name ${job.name} on queue ${queueName}`,
);
await handler({ data: job.data, id: job.id ?? '', name: job.name });
this.logger.log(
`Job ${job.id} with name ${job.name} processed on queue ${queueName}`,
);
},
workerOptions,
);