Compare commits

...
Author SHA1 Message Date
Sonarly Claude Code 0764eb55d7 Relaunch job doesn't reset throttleFailureCount, causing fail-relaunch loop on Gmail rate limits
https://sonarly.com/issue/3777?type=bug

When Gmail returns a user-rate limit error (HTTP 429) and a message channel exhausts 5 retry attempts, it's marked as FAILED_UNKNOWN. The auto-relaunch cron (every 30 min) restores the channel without resetting throttleFailureCount, so any subsequent rate-limit hit immediately re-fails the channel and fires another Sentry alert, creating an infinite fail→relaunch→fail cycle.

Fix: The fix adds `throttleFailureCount: 0` and `throttleRetryAfter: null` to the update query in the relaunch job, so that when a failed channel is relaunched, its throttle state is fully reset alongside `syncStage` and `syncStatus`.

Without this fix, after relaunch the channel still has `throttleFailureCount >= 5`, so the very next Gmail rate-limit response immediately re-triggers `handleTemporaryException`'s failure path (`count >= MESSAGING_THROTTLE_MAX_ATTEMPTS`), marks the channel `FAILED_UNKNOWN` again, fires another Sentry alert, and perpetuates the infinite fail→relaunch→fail cycle.

```typescript file=packages/twenty-server/src/modules/messaging/message-import-manager/jobs/messaging-relaunch-failed-message-channel.job.ts lines=61-66
await messageChannelRepository.update(messageChannelId, {
  syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
  syncStatus: MessageChannelSyncStatus.ACTIVE,
  throttleFailureCount: 0,
  throttleRetryAfter: null,
});
```
2026-03-04 20:50:36 +00:00
@@ -61,6 +61,8 @@ export class MessagingRelaunchFailedMessageChannelJob {
await messageChannelRepository.update(messageChannelId, {
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
syncStatus: MessageChannelSyncStatus.ACTIVE,
throttleFailureCount: 0,
throttleRetryAfter: null,
});
}, authContext);
}