fix message channels stuck in ONGOING (#17492)
`markAsMessagesListFetchOngoing()` was missing `syncStageStartedAt`
causing stuck channels to be never recovered.
Regression was caused by commit
[68a9ef57f0](https://github.com/twentyhq/twenty/commit/68a9ef57f0)
This commit is contained in:
+1
-4
@@ -54,10 +54,7 @@ export class CalendarOngoingStaleJob {
|
||||
});
|
||||
|
||||
for (const calendarChannel of calendarChannels) {
|
||||
if (
|
||||
calendarChannel.syncStageStartedAt &&
|
||||
isSyncStale(calendarChannel.syncStageStartedAt)
|
||||
) {
|
||||
if (isSyncStale(calendarChannel.syncStageStartedAt)) {
|
||||
await this.calendarChannelSyncStatusService.resetSyncStageStartedAt(
|
||||
[calendarChannel.id],
|
||||
workspaceId,
|
||||
|
||||
+7
-1
@@ -1,6 +1,12 @@
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { CALENDAR_IMPORT_ONGOING_SYNC_TIMEOUT } from 'src/modules/calendar/calendar-event-import-manager/constants/calendar-import-ongoing-sync-timeout.constant';
|
||||
|
||||
export const isSyncStale = (syncStageStartedAt: string): boolean => {
|
||||
export const isSyncStale = (syncStageStartedAt?: string | null): boolean => {
|
||||
if (!isDefined(syncStageStartedAt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const syncStageStartedTime = new Date(syncStageStartedAt).getTime();
|
||||
|
||||
if (isNaN(syncStageStartedTime)) {
|
||||
|
||||
+1
@@ -182,6 +182,7 @@ export class CalendarChannelSyncStatusService {
|
||||
await calendarChannelRepository.update(calendarChannelIds, {
|
||||
syncStage: CalendarChannelSyncStage.CALENDAR_EVENTS_IMPORT_ONGOING,
|
||||
syncStatus: CalendarChannelSyncStatus.ONGOING,
|
||||
syncStageStartedAt: new Date().toISOString(),
|
||||
});
|
||||
}, authContext);
|
||||
}
|
||||
|
||||
+2
@@ -199,6 +199,7 @@ export class MessageChannelSyncStatusService {
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_ONGOING,
|
||||
syncStatus: MessageChannelSyncStatus.ONGOING,
|
||||
syncStageStartedAt: new Date().toISOString(),
|
||||
});
|
||||
}, authContext);
|
||||
}
|
||||
@@ -277,6 +278,7 @@ export class MessageChannelSyncStatusService {
|
||||
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStage: MessageChannelSyncStage.MESSAGES_IMPORT_ONGOING,
|
||||
syncStatus: MessageChannelSyncStatus.ONGOING,
|
||||
syncStageStartedAt: new Date().toISOString(),
|
||||
});
|
||||
}, authContext);
|
||||
|
||||
+1
-4
@@ -54,10 +54,7 @@ export class MessagingOngoingStaleJob {
|
||||
});
|
||||
|
||||
for (const messageChannel of messageChannels) {
|
||||
if (
|
||||
messageChannel.syncStageStartedAt &&
|
||||
isSyncStale(messageChannel.syncStageStartedAt)
|
||||
) {
|
||||
if (isSyncStale(messageChannel.syncStageStartedAt)) {
|
||||
await this.messageChannelSyncStatusService.resetSyncStageStartedAt(
|
||||
[messageChannel.id],
|
||||
workspaceId,
|
||||
|
||||
+13
-1
@@ -24,7 +24,19 @@ describe('isSyncStale', () => {
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if syncStageStartedAt is invalid', () => {
|
||||
it('should return false if syncStageStartedAt is undefined', () => {
|
||||
const result = isSyncStale(undefined);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if syncStageStartedAt is null', () => {
|
||||
const result = isSyncStale(null);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should throw an error if syncStageStartedAt is invalid', () => {
|
||||
const syncStageStartedAt = 'invalid-date';
|
||||
|
||||
expect(() => {
|
||||
|
||||
+7
-1
@@ -1,6 +1,12 @@
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { MESSAGING_IMPORT_ONGOING_SYNC_TIMEOUT } from 'src/modules/messaging/message-import-manager/constants/messaging-import-ongoing-sync-timeout.constant';
|
||||
|
||||
export const isSyncStale = (syncStageStartedAt: string): boolean => {
|
||||
export const isSyncStale = (syncStageStartedAt?: string | null): boolean => {
|
||||
if (!isDefined(syncStageStartedAt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const syncStageStartedTime = new Date(syncStageStartedAt).getTime();
|
||||
|
||||
if (isNaN(syncStageStartedTime)) {
|
||||
|
||||
Reference in New Issue
Block a user