Skip to content

Scheduling infrastructure for absolutely everyone.

fix: single rejection caused cache cron to fail (#18239)

Omar López4d192ee3283a
diff --git a/packages/features/calendar-cache/api/cron.ts b/packages/features/calendar-cache/api/cron.ts
index 63faac20c6c..ffa9cf738fe 100644
--- a/packages/features/calendar-cache/api/cron.ts
+++ b/packages/features/calendar-cache/api/cron.ts
@@ -41,22 +41,11 @@ const handleCalendarsToWatch = async () => {
// This cron is used to activate and renew calendar subcriptions
const handler = defaultResponder(async (request: NextApiRequest) => {
validateRequest(request);
- const [watchedResult, unwatchedResult] = await Promise.all([
- handleCalendarsToWatch(),
- handleCalendarsToUnwatch(),
- ]);
+ await Promise.allSettled([handleCalendarsToWatch(), handleCalendarsToUnwatch()]);
// TODO: Credentials can be installed on a whole team, check for selected calendars on the team
return {
- succeededAt: new Date().toISOString(),
- watched: {
- successful: watchedResult.filter((x) => x.status === "fulfilled").length,
- failed: watchedResult.filter((x) => x.status === "rejected").length,
- },
- unwatched: {
- successful: unwatchedResult.filter((x) => x.status === "fulfilled").length,
- failed: unwatchedResult.filter((x) => x.status === "rejected").length,
- },
+ executedAt: new Date().toISOString(),
};
});
diff --git a/packages/lib/server/repository/selectedCalendar.ts b/packages/lib/server/repository/selectedCalendar.ts
index 7c851a0c719..ed0e00ed206 100644
--- a/packages/lib/server/repository/selectedCalendar.ts
+++ b/packages/lib/server/repository/selectedCalendar.ts
@@ -1,6 +1,5 @@
import type { Prisma } from "@prisma/client";
-import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import { prisma } from "@calcom/prisma";
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
@@ -64,12 +63,7 @@ export class SelectedCalendarRepository {
// RN we only support google calendar subscriptions for now
integration: "google_calendar",
googleChannelExpiration: { not: null },
- };
- const featureRepo = new FeaturesRepository();
- const calendarCache = await featureRepo.checkIfFeatureIsEnabledGlobally("calendar-cache");
- // If calendar cache is disabled globally, we skip team features and unwatch all subscriptions
- if (!calendarCache) {
- where.user = {
+ user: {
teams: {
every: {
team: {
@@ -81,8 +75,9 @@ export class SelectedCalendarRepository {
},
},
},
- };
- }
+ },
+ };
+ // If calendar cache is disabled globally, we skip team features and unwatch all subscriptions
const nextBatch = await prisma.selectedCalendar.findMany({
take: limit,
where,