Skip to content

Microsoft sync - Mailbox concurrency issues #11070

Description

@kar-re

Bug Description

When syncing a Microsoft account, a MailboxConcurrency throttle issue is reported from the Microsoft Graph API.
Ex.

 MessageImportException [Error]: Unknown error occurred while importing messages for message channel 72dc8f2c-156e-45e7-8dbf-cba320346b92 in workspace e7a4c51f-4415-4cb9-b4ea-7def87c05649: Microsoft Graph API unknown error: Error: Microsoft Graph API error: Application is over its MailboxConcurrency limit.

This leads to the total import being canceled, instead of retrying after a while.

Expected behavior

Syncing should continue or retry after a fixed time

Technical inputs

The wierd thing is that it succeeds for three requests but then fails:

worker-1  | [Nest] 34  - 03/20/2025, 3:40:44 PM     LOG [MessagingMessageListFetchJob] Fetching full message list for workspace e7a4c51f-4415-4cb9-b4ea-7def87c05649 and account 26efae74-5545-4d82-b0aa-05e3187c2976
.
.
.
worker-1  | [Nest] 34  - 03/20/2025, 3:42:00 PM     LOG [MessagingMessagesImportService] Messaging import for workspace e7a4c51f-4415-4cb9-b4ea-7def87c05649 and account 26efae74-5545-4d82-b0aa-05e3187c2976 starting...
db-1      | 2025-03-20 15:42:03.145 UTC [24] LOG {ticks: 0, maint: 0, retry: 0}
db-1      | 2025-03-20 15:42:05,926 INFO: no action. I am (ccf62911b2bd), the leader with the lock
worker-1  | [Nest] 34  - 03/20/2025, 3:42:12 PM     LOG [MicrosoftGetMessagesService] Messaging import for workspace e7a4c51f-4415-4cb9-b4ea-7def87c05649 and account 26efae74-5545-4d82-b0aa-05e3187c2976 fetched 200 messages in 12053ms
.
.
worker-1  | [Nest] 34  - 03/20/2025, 3:43:00 PM     LOG [MessagingMessagesImportService] Messaging import for workspace e7a4c51f-4415-4cb9-b4ea-7def87c05649 and account 26efae74-5545-4d82-b0aa-05e3187c2976 starting...
db-1      | 2025-03-20 15:43:03.177 UTC [24] LOG {ticks: 0, maint: 0, retry: 0}
db-1      | 2025-03-20 15:43:05,919 INFO: no action. I am (ccf62911b2bd), the leader with the lock
worker-1  | [Nest] 34  - 03/20/2025, 3:43:12 PM     LOG [MicrosoftGetMessagesService] Messaging import for workspace e7a4c51f-4415-4cb9-b4ea-7def87c05649 and account 26efae74-5545-4d82-b0aa-05e3187c2976 fetched 200 messages in 11385ms
.
.
worker-1  | [Nest] 34  - 03/20/2025, 3:44:00 PM     LOG [MessagingMessagesImportService] Messaging import for workspace e7a4c51f-4415-4cb9-b4ea-7def87c05649 and account 26efae74-5545-4d82-b0aa-05e3187c2976 starting...
db-1      | 2025-03-20 15:44:03.203 UTC [24] LOG {ticks: 0, maint: 0, retry: 0}
db-1      | 2025-03-20 15:44:05,920 INFO: no action. I am (ccf62911b2bd), the leader with the lock
worker-1  | Exception Captured
worker-1  |   undefined
worker-1  |   [
worker-1  |     MessageImportException [Error]: Unknown error occurred while importing messages for message channel 82b6415c-667f-4a15-b4a0-14db22e90b3c in workspace e7a4c51f-4415-4cb9-b4ea-7def87c05649: Microsoft Graph API unknown error: Error: Microsoft Graph API error: Application is over its MailboxConcurrency limit.
worker-1  |         at MessageImportExceptionHandlerService.handleUnknownException (/app/packages/twenty-server/dist/src/modules/messaging/message-import-manager/services/messaging-import-exception-handler.service.js:104:15)
worker-1  |         at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
worker-1  |         at async MessageImportExceptionHandlerService.handleDriverException (/app/packages/twenty-server/dist/src/modules/messaging/message-import-manager/services/messaging-import-exception-handler.service.js:55:17)
worker-1  |         at async MessagingMessagesImportService.processMessageBatchImport (/app/packages/twenty-server/dist/src/modules/messaging/message-import-manager/services/messaging-messages-import.service.js:122:13)
worker-1  |         at async MessagingMessagesImportJob.handle (/app/packages/twenty-server/dist/src/modules/messaging/message-import-manager/jobs/messaging-messages-import.job.js:63:9)
worker-1  |         at async MessageQueueExplorer.invokeProcessMethods (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:111:17)
worker-1  |         at async MessageQueueExplorer.handleProcessor (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:103:13)
worker-1  |         at async /app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:79:17
worker-1  |         at async Worker.processFn (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/drivers/bullmq.driver.js:41:13)
worker-1  |         at async /app/node_modules/bullmq/dist/cjs/classes/worker.js:520:32 {
worker-1  |       code: 'UNKNOWN'
worker-1  |     }
worker-1  |   ]

It could have something todo with the cron job frequency? Or the batchLimit here?

Thank you for a great project! 😊

CC: @guillim

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

Priority

None yet

Dev status

None yet

Start date

None yet

Target date

None yet

Quarter

None yet

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions