Skip to content

Commit 924156b

Browse files
committed
🐛 Fix: Handle NoSyncToken error during gcal notification
logs instead message instead of full error to signify that this is a known scenario and not something we need to do anything about
1 parent f007c6a commit 924156b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/backend/src/common/constants/error.constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export const SyncError = {
186186
},
187187
NoSyncToken: {
188188
description: "No syncToken",
189-
status: Status.NO_CONTENT,
189+
status: Status.INTERNAL_SERVER,
190190
isOperational: true,
191191
},
192192
NoEventChanges: {

packages/backend/src/sync/controllers/sync.controller.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { Request } from "express";
22
import { Status } from "@core/errors/status.codes";
33
import { Logger } from "@core/logger/winston.logger";
44
import { Payload_Sync_Notif } from "@core/types/sync.types";
5-
import { UserError } from "@backend/common/constants/error.constants";
5+
import {
6+
SyncError,
7+
UserError,
8+
} from "@backend/common/constants/error.constants";
69
import {
710
isFullSyncRequired,
811
isInvalidGoogleToken,
@@ -61,6 +64,18 @@ class SyncController {
6164
res.status(Status.OK).send(result);
6265
return;
6366
}
67+
if (
68+
e instanceof Error &&
69+
e.message === SyncError.NoSyncToken.description
70+
) {
71+
logger.debug(
72+
`Ignored notification due to missing sync token for resourceId: ${resourceId}`,
73+
);
74+
// returning 204 instead of 500 so client doesn't
75+
// attempt to retry
76+
res.status(Status.NO_CONTENT).send();
77+
return;
78+
}
6479

6580
logger.error("Not sure how to handle this error:");
6681
logger.error(e);

0 commit comments

Comments
 (0)