Fix bull-mq retry option and exceptions not being captured for jobs (#3905)

* Fix bull-mq retry option

* fix exception inside worker

* add logs

* fix after review
This commit is contained in:
Weiko
2024-02-12 15:12:52 +01:00
committed by GitHub
parent 1265dc74d0
commit c13e55a753
6 changed files with 15 additions and 11 deletions

View File

@ -93,7 +93,11 @@ export class BullMQDriver implements MessageQueueDriver {
`Queue ${queueName} is not registered, make sure you have added it as a queue provider`,
);
}
const queueOptions = { jobId: options?.id, priority: options?.priority };
const queueOptions = {
jobId: options?.id,
priority: options?.priority,
attempts: 1 + (options?.retryLimit || 0),
};
await this.queueMap[queueName].add(jobName, data, queueOptions);
}

View File

@ -39,7 +39,12 @@ async function bootstrap() {
.select(JobsModule)
.get(jobClassName, { strict: true });
await job.handle(jobData.data);
try {
await job.handle(jobData.data);
} catch (err) {
exceptionHandlerService?.captureExceptions([err]);
throw err;
}
});
}
} catch (err) {

View File

@ -75,7 +75,6 @@ export class GmailFullSyncCommand extends CommandRunner {
connectedAccountId: connectedAccount.id,
},
{
id: `${workspaceId}-${connectedAccount.id}`,
retryLimit: 2,
},
);

View File

@ -75,7 +75,6 @@ export class GmailPartialSyncCommand extends CommandRunner {
connectedAccountId: connectedAccount.id,
},
{
id: `${workspaceId}-${connectedAccount.id}`,
retryLimit: 2,
},
);

View File

@ -37,13 +37,6 @@ export class MessagingPersonListener {
@OnEvent('person.updated')
handleUpdatedEvent(payload: ObjectRecordUpdateEvent<PersonObjectMetadata>) {
console.log(
objectRecordUpdateEventChangedProperties(
payload.previousRecord,
payload.updatedRecord,
),
);
if (
objectRecordUpdateEventChangedProperties(
payload.previousRecord,

View File

@ -109,6 +109,10 @@ export class GmailFullSyncService {
);
if (messagesToSave.length === 0) {
this.logger.log(
`gmail full-sync for workspace ${workspaceId} and account ${connectedAccountId} done with nothing to import.`,
);
return;
}