Skip to content

The open alternative to Salesforce, designed for AI.

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

Weikoc13e55a75378
diff --git a/packages/twenty-server/src/integrations/message-queue/drivers/bullmq.driver.ts b/packages/twenty-server/src/integrations/message-queue/drivers/bullmq.driver.ts
index f1106b760fb..0ea7857de2e 100644
--- a/packages/twenty-server/src/integrations/message-queue/drivers/bullmq.driver.ts
+++ b/packages/twenty-server/src/integrations/message-queue/drivers/bullmq.driver.ts
@@ -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);
}
diff --git a/packages/twenty-server/src/queue-worker.ts b/packages/twenty-server/src/queue-worker.ts
index e057f2b1b9d..9f7b0cec5fd 100644
--- a/packages/twenty-server/src/queue-worker.ts
+++ b/packages/twenty-server/src/queue-worker.ts
@@ -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) {
diff --git a/packages/twenty-server/src/workspace/messaging/commands/gmail-full-sync.command.ts b/packages/twenty-server/src/workspace/messaging/commands/gmail-full-sync.command.ts
index 81837964ccc..15c460f49b6 100644
--- a/packages/twenty-server/src/workspace/messaging/commands/gmail-full-sync.command.ts
+++ b/packages/twenty-server/src/workspace/messaging/commands/gmail-full-sync.command.ts
@@ -75,7 +75,6 @@ export class GmailFullSyncCommand extends CommandRunner {
connectedAccountId: connectedAccount.id,
},
{
- id: `${workspaceId}-${connectedAccount.id}`,
retryLimit: 2,
},
);
diff --git a/packages/twenty-server/src/workspace/messaging/commands/gmail-partial-sync.command.ts b/packages/twenty-server/src/workspace/messaging/commands/gmail-partial-sync.command.ts
index ddadd8c2543..b64f93b2e92 100644
--- a/packages/twenty-server/src/workspace/messaging/commands/gmail-partial-sync.command.ts
+++ b/packages/twenty-server/src/workspace/messaging/commands/gmail-partial-sync.command.ts
@@ -75,7 +75,6 @@ export class GmailPartialSyncCommand extends CommandRunner {
connectedAccountId: connectedAccount.id,
},
{
- id: `${workspaceId}-${connectedAccount.id}`,
retryLimit: 2,
},
);
diff --git a/packages/twenty-server/src/workspace/messaging/listeners/messaging-person.listener.ts b/packages/twenty-server/src/workspace/messaging/listeners/messaging-person.listener.ts
index 3831249644d..ab909bc709b 100644
--- a/packages/twenty-server/src/workspace/messaging/listeners/messaging-person.listener.ts
+++ b/packages/twenty-server/src/workspace/messaging/listeners/messaging-person.listener.ts
@@ -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,
diff --git a/packages/twenty-server/src/workspace/messaging/services/gmail-full-sync.service.ts b/packages/twenty-server/src/workspace/messaging/services/gmail-full-sync.service.ts
index 019b963b39a..55a34a8bc0a 100644
--- a/packages/twenty-server/src/workspace/messaging/services/gmail-full-sync.service.ts
+++ b/packages/twenty-server/src/workspace/messaging/services/gmail-full-sync.service.ts
@@ -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;
}