Message fixes (#16389)
In this PR: - add more logs to troubleshoot issues in production - use messageChannelSyncStatus in messageSync service instead of making a manual update
This commit is contained in:
@@ -48,6 +48,9 @@ export function formatData<T>(
|
||||
const fieldMetadata = flatFieldMetadataMaps.byId[fieldMetadataId];
|
||||
|
||||
if (!fieldMetadata) {
|
||||
this.logger.warn(
|
||||
`Field metadata for field "${key}" is missing in object metadata ${flatObjectMetadata.nameSingular} for data: ${JSON.stringify(data)}`,
|
||||
);
|
||||
throw new Error(
|
||||
`Field metadata for field "${key}" is missing in object metadata ${flatObjectMetadata.nameSingular}`,
|
||||
);
|
||||
|
||||
+6
-1
@@ -4,9 +4,14 @@ import { PermissionsModule } from 'src/engine/metadata-modules/permissions/permi
|
||||
import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
|
||||
import { ChannelSyncResolver } from 'src/modules/connected-account/channel-sync/channel-sync.resolver';
|
||||
import { ChannelSyncService } from 'src/modules/connected-account/channel-sync/services/channel-sync.service';
|
||||
import { MessagingCommonModule } from 'src/modules/messaging/common/messaging-common.module';
|
||||
|
||||
@Module({
|
||||
imports: [PermissionsModule, WorkspaceDataSourceModule],
|
||||
imports: [
|
||||
PermissionsModule,
|
||||
WorkspaceDataSourceModule,
|
||||
MessagingCommonModule,
|
||||
],
|
||||
providers: [ChannelSyncResolver, ChannelSyncService],
|
||||
exports: [ChannelSyncService],
|
||||
})
|
||||
|
||||
+6
-5
@@ -13,9 +13,9 @@ import {
|
||||
CalendarChannelSyncStatus,
|
||||
type CalendarChannelWorkspaceEntity,
|
||||
} from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity';
|
||||
import { MessageChannelSyncStatusService } from 'src/modules/messaging/common/services/message-channel-sync-status.service';
|
||||
import {
|
||||
MessageChannelSyncStage,
|
||||
MessageChannelSyncStatus,
|
||||
type MessageChannelWorkspaceEntity,
|
||||
} from 'src/modules/messaging/common/standard-objects/message-channel.workspace-entity';
|
||||
import {
|
||||
@@ -36,6 +36,7 @@ export class ChannelSyncService {
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
@InjectMessageQueue(MessageQueue.calendarQueue)
|
||||
private readonly calendarQueueService: MessageQueueService,
|
||||
private readonly messageChannelSyncStatusService: MessageChannelSyncStatusService,
|
||||
) {}
|
||||
|
||||
async startChannelSync(input: StartChannelSyncInput): Promise<void> {
|
||||
@@ -63,10 +64,10 @@ export class ChannelSyncService {
|
||||
});
|
||||
|
||||
for (const messageChannel of messageChannels) {
|
||||
await messageChannelRepository.update(messageChannel.id, {
|
||||
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_SCHEDULED,
|
||||
syncStatus: MessageChannelSyncStatus.ONGOING,
|
||||
});
|
||||
await this.messageChannelSyncStatusService.markAsMessagesListFetchScheduled(
|
||||
[messageChannel.id],
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
await this.messageQueueService.add<MessagingMessageListFetchJobData>(
|
||||
MessagingMessageListFetchJob.name,
|
||||
|
||||
+3
-1
@@ -16,7 +16,9 @@ export class GmailFoldersErrorHandlerService {
|
||||
constructor() {}
|
||||
|
||||
public handleError(error: unknown): void {
|
||||
this.logger.error(`Gmail: Error fetching folders: ${error}`);
|
||||
this.logger.error(
|
||||
`Gmail: Error fetching folders: ${JSON.stringify(error)}`,
|
||||
);
|
||||
if (isGmailNetworkError(error)) {
|
||||
throw parseGmailNetworkError(error);
|
||||
}
|
||||
|
||||
+3
-1
@@ -16,7 +16,9 @@ export class GmailMessageListFetchErrorHandler {
|
||||
constructor() {}
|
||||
|
||||
public handleError(error: unknown): void {
|
||||
this.logger.error(`Gmail: Error fetching message list: ${error}`);
|
||||
this.logger.error(
|
||||
`Gmail: Error fetching message list: ${JSON.stringify(error)}`,
|
||||
);
|
||||
if (isGmailNetworkError(error)) {
|
||||
throw parseGmailNetworkError(error);
|
||||
}
|
||||
|
||||
+3
-1
@@ -18,7 +18,9 @@ export class GmailMessagesImportErrorHandler {
|
||||
constructor() {}
|
||||
|
||||
public handleError(error: unknown, messageExternalId: string): void {
|
||||
this.logger.error(`Gmail: Error importing messages: ${error}`);
|
||||
this.logger.error(
|
||||
`Gmail: Error importing messages: ${JSON.stringify(error)}`,
|
||||
);
|
||||
|
||||
if (isGmailNetworkError(error)) {
|
||||
throw parseGmailNetworkError(error);
|
||||
|
||||
+3
-1
@@ -8,7 +8,9 @@ export class ImapMessageListFetchErrorHandler {
|
||||
private readonly logger = new Logger(ImapMessageListFetchErrorHandler.name);
|
||||
|
||||
public handleError(error: Error): void {
|
||||
this.logger.error(`IMAP: Error fetching message list: ${error.message}`);
|
||||
this.logger.error(
|
||||
`IMAP: Error fetching message list: ${JSON.stringify(error)}`,
|
||||
);
|
||||
|
||||
const networkError = parseImapError(error, { cause: error });
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ export class ImapMessagesImportErrorHandler {
|
||||
|
||||
public handleError(error: Error, messageExternalId: string): void {
|
||||
this.logger.error(
|
||||
`IMAP: Error importing message ${messageExternalId}: ${error.message}`,
|
||||
`IMAP: Error importing message ${messageExternalId}: ${JSON.stringify(error)}`,
|
||||
);
|
||||
|
||||
const networkError = parseImapError(error, { cause: error });
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ export class MicrosoftMessageListFetchErrorHandler {
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
public handleError(error: any): void {
|
||||
this.logger.log(`Error fetching message list`, error);
|
||||
this.logger.log(`Error fetching message list: ${JSON.stringify(error)}`);
|
||||
|
||||
const networkError = this.microsoftNetworkErrorHandler.handleError(error);
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ export class MicrosoftMessagesImportErrorHandler {
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
public handleError(error: any): void {
|
||||
this.logger.log(`Error fetching messages`, error);
|
||||
this.logger.log(`Error fetching messages: ${JSON.stringify(error)}`);
|
||||
|
||||
const networkError = this.microsoftNetworkErrorHandler.handleError(error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user