crbench//

← all cases

Async import of the appStore packages

Tier 2 easy typescript · local · real merged PR from calcom/cal.com #8087

Ground-truth defects

d3 · correctness · medium
In wipemycalother/vital reschedule.ts the loop stayed `forEach(async (bookingRef) => { await getCalendar(...); ... })`, so the async callbacks run detached and the surrounding try/catch returns before they settle — errors from the now-async getCalendar (previously caught synchronously) and deleteEvent/deleteMeeting are no longer caught and surface as unhandled rejections instead of being logged, unlike the `for...of`+await fix applied in handleCancelBooking's else branch.

The change under review

diff
diff --git a/packages/app-store/_utils/getCalendar.ts b/packages/app-store/_utils/getCalendar.ts
index 8a329485f1..10c60ed1c3 100644
--- a/packages/app-store/_utils/getCalendar.ts
+++ b/packages/app-store/_utils/getCalendar.ts
@@ -6,13 +6,13 @@ import appStore from "..";
 
 const log = logger.getChildLogger({ prefix: ["CalendarManager"] });
 
-export const getCalendar = (credential: CredentialPayload | null): Calendar | null => {
+export const getCalendar = async (credential: CredentialPayload | null): Promise<Calendar | null> => {
   if (!credential || !credential.key) return null;
   let { type: calendarType } = credential;
   if (calendarType?.endsWith("_other_calendar")) {
     calendarType = calendarType.split("_other_calendar")[0];
   }
-  const calendarApp = appStore[calendarType.split("_").join("") as keyof typeof appStore];
+  const calendarApp = await appStore[calendarType.split("_").join("") as keyof typeof appStore];
   if (!(calendarApp && "lib" in calendarApp && "CalendarService" in calendarApp.lib)) {
     log.warn(`calendar of type ${calendarType} is not implemented`);
     return null;
diff --git a/packages/app-store/index.ts b/packages/app-store/index.ts
index 2aacc6731b..e232b9fa4f 100644
--- a/packages/app-store/index.ts
+++ b/packages/app-store/index.ts
@@ -1,63 +1,33 @@
-// import * as example from "./_example";
-import * as applecalendar from "./applecalendar";
-import * as caldavcalendar from "./caldavcalendar";
-import * as closecom from "./closecom";
-import * as dailyvideo from "./dailyvideo";
-import * as exchange2013calendar from "./exchange2013calendar";
-import * as exchange2016calendar from "./exchange2016calendar";
-import * as exchangecalendar from "./exchangecalendar";
-import * as facetime from "./facetime";
-import * as giphy from "./giphy";
-import * as googlecalendar from "./googlecalendar";
-import * as googlevideo from "./googlevideo";
-import * as hubspot from "./hubspot";
-import * as huddle01video from "./huddle01video";
-import * as jitsivideo from "./jitsivideo";
-import * as larkcalendar from "./larkcalendar";
-import * as office365calendar from "./office365calendar";
-import * as office365video from "./office365video";
-import * as plausible from "./plausible";
-import * as salesforce from "./salesforce";
-import * as sendgrid from "./sendgrid";
-import * as stripepayment from "./stripepayment";
-import * as sylapsvideo from "./sylapsvideo";
-import * as tandemvideo from "./tandemvideo";
-import * as vital from "./vital";
-import * as wipemycalother from "./wipemycalother";
-import * as zapier from "./zapier";
-import * as zohocrm from "./zohocrm";
-import * as zoomvideo from "./zoomvideo";
-
 const appStore = {
-  //   example,
-  applecalendar,
-  caldavcalendar,
-  closecom,
-  dailyvideo,
-  googlecalendar,
-  googlevideo,
-  hubspot,
-  huddle01video,
-  jitsivideo,
-  sylapsvideo,
-  larkcalendar,
-  office365calendar,
-  office365video,
-  plausible,
-  salesforce,
-  zohocrm,
-  sendgrid,
-  stripepayment,
-  tandemvideo,
-  vital,
-  zoomvideo,
-  wipemycalother,
-  giphy,
-  zapier,
-  exchange2013calendar,
-  exchange2016calendar,
-  exchangecalendar,
-  facetime,
+  // example: import("./example"),
+  applecalendar: import("./applecalendar"),
+  caldavcalendar: import("./caldavcalendar"),
+  closecom: import("./closecom"),
+  dailyvideo: import("./dailyvideo"),
+  googlecalendar: import("./googlecalendar"),
+  googlevideo: import("./googlevideo"),
+  hubspot: import("./hubspot"),
+  huddle01video: import("./huddle01video"),
+  jitsivideo: import("./jitsivideo"),
+  larkcalendar: import("./larkcalendar"),
+  office365calendar: import("./office365calendar"),
+  office365video: import("./office365video"),
+  plausible: import("./plausible"),
+  salesforce: import("./salesforce"),
+  zohocrm: import("./zohocrm"),
+  sendgrid: import("./sendgrid"),
+  stripepayment: import("./stripepayment"),
+  tandemvideo: import("./tandemvideo"),
+  vital: import("./vital"),
+  zoomvideo: import("./zoomvideo"),
+  wipemycalother: import("./wipemycalother"),
+  giphy: import("./giphy"),
+  zapier: import("./zapier"),
+  exchange2013calendar: import("./exchange2013calendar"),
+  exchange2016calendar: import("./exchange2016calendar"),
+  exchangecalendar: import("./exchangecalendar"),
+  facetime: import("./facetime"),
+  sylapsvideo: import("./sylapsvideo"),
 };
 
 export default appStore;
diff --git a/packages/app-store/vital/lib/reschedule.ts b/packages/app-store/vital/lib/reschedule.ts
index d216a987cf..07733c58ef 100644
--- a/packages/app-store/vital/lib/reschedule.ts
+++ b/packages/app-store/vital/lib/reschedule.ts
@@ -122,10 +122,10 @@ const Reschedule = async (bookingUid: string, cancellationReason: string) => {
       (ref) => !!credentialsMap.get(ref.type)
     );
     try {
-      bookingRefsFiltered.forEach((bookingRef) => {
+      bookingRefsFiltered.forEach(async (bookingRef) => {
         if (bookingRef.uid) {
           if (bookingRef.type.endsWith("_calendar")) {
-            const calendar = getCalendar(credentialsMap.get(bookingRef.type));
+            const calendar = await getCalendar(credentialsMap.get(bookingRef.type));
             return calendar?.deleteEvent(bookingRef.uid, builder.calendarEvent);
           } else if (bookingRef.type.endsWith("_video")) {
             return deleteMeeting(credentialsMap.get(bookingRef.type), bookingRef.uid);
diff --git a/packages/app-store/wipemycalother/lib/reschedule.ts b/packages/app-store/wipemycalother/lib/reschedule.ts
index 5e735097f2..bf62fdc5af 100644
--- a/packages/app-store/wipemycalother/lib/reschedule.ts
+++ b/packages/app-store/wipemycalother/lib/reschedule.ts
@@ -122,10 +122,10 @@ const Reschedule = async (bookingUid: string, cancellationReason: string) => {
       (ref) => !!credentialsMap.get(ref.type)
     );
     try {
-      bookingRefsFiltered.forEach((bookingRef) => {
+      bookingRefsFiltered.forEach(async (bookingRef) => {
         if (bookingRef.uid) {
           if (bookingRef.type.endsWith("_calendar")) {
-            const calendar = getCalendar(credentialsMap.get(bookingRef.type));
+            const calendar = await getCalendar(credentialsMap.get(bookingRef.type));
             return calendar?.deleteEvent(bookingRef.uid, builder.calendarEvent);
           } else if (bookingRef.type.endsWith("_video")) {
             return deleteMeeting(credentialsMap.get(bookingRef.type), bookingRef.uid);
diff --git a/packages/core/CalendarManager.ts b/packages/core/CalendarManager.ts
index 4d5bf3103e..9a5c312949 100644
--- a/packages/core/CalendarManager.ts
+++ b/packages/core/CalendarManager.ts
@@ -28,6 +28,7 @@ export const getCalendarCredentials = (credentials: Array<CredentialPayload>) =>
         const calendar = getCalendar(credential);
         return app.variant === "calendar" ? [{ integration: app, credential, calendar }] : [];
       });
+
       return credentials.length ? credentials : [];
     });
 
@@ -43,8 +44,8 @@ export const getConnectedCalendars = async (
   const connectedCalendars = await Promise.all(
     calendarCredentials.map(async (item) => {
       try {
-        const { calendar, integration, credential } = item;
-
+        const { integration, credential } = item;
+        const calendar = await item.calendar;
         // Don't leak credentials to the client
         const credentialId = credential.id;
         if (!calendar) {
@@ -138,7 +139,7 @@ export const getCachedResults = async (
   selectedCalendars: SelectedCalendar[]
 ): Promise<EventBusyDate[][]> => {
   const calendarCredentials = withCredentials.filter((credential) => credential.type.endsWith("_calendar"));
-  const calendars = calendarCredentials.map((credential) => getCalendar(credential));
+  const calendars = await Promise.all(calendarCredentials.map((credential) => getCalendar(credential)));
   performance.mark("getBusyCalendarTimesStart");
   const results = calendars.map(async (c, i) => {
     /** Filter out nulls */
@@ -229,7 +230,7 @@ export const createEvent = async (
   calEvent: CalendarEvent
 ): Promise<EventResult<NewCalendarEventType>> => {
   const uid: string = getUid(calEvent);
-  const calendar = getCalendar(credential);
+  const calendar = await getCalendar(credential);
   let success = true;
   let calError: string | undefined = undefined;
 
@@ -280,7 +281,7 @@ export const updateEvent = async (
   externalCalendarId: string | null
 ): Promise<EventResult<NewCalendarEventType>> => {
   const uid = getUid(calEvent);
-  const calendar = getCalendar(credential);
+  const calendar = await getCalendar(credential);
   let success = false;
   let calError: string | undefined = undefined;
   let calWarnings: string[] | undefined = [];
@@ -326,12 +327,12 @@ export const updateEvent = async (
   };
 };
 
-export const deleteEvent = (
+export const deleteEvent = async (
   credential: CredentialPayload,
   uid: string,
   event: CalendarEvent
 ): Promise<unknown> => {
-  const calendar = getCalendar(credential);
+  const calendar = await getCalendar(credential);
   if (calendar) {
     return calendar.deleteEvent(uid, event);
   }
diff --git a/packages/core/EventManager.ts b/packages/core/EventManager.ts
index d8bc62d544..4b3b3564b1 100644
--- a/packages/core/EventManager.ts
+++ b/packages/core/EventManager.ts
@@ -485,8 +485,7 @@ export default class EventManager {
               id: oldCalendarEvent.credentialId,
             },
           });
-          const calendar = getCalendar(calendarCredential);
-
+          const calendar = await getCalendar(calendarCredential);
           await calendar?.deleteEvent(oldCalendarEvent.uid, event, oldCalendarEvent.externalCalendarId);
         }
       }
diff --git a/packages/core/videoClient.ts b/packages/core/videoClient.ts
index ff5308b956..06887ce96d 100644
--- a/packages/core/videoClient.ts
+++ b/packages/core/videoClient.ts
@@ -18,21 +18,25 @@ const log = logger.getChildLogger({ prefix: ["[lib] videoClient"] });
 const translator = short();
 
 // factory
-const getVideoAdapters = (withCredentials: CredentialPayload[]): VideoApiAdapter[] =>
-  withCredentials.reduce<VideoApiAdapter[]>((acc, cred) => {
+const getVideoAdapters = async (withCredentials: CredentialPayload[]): Promise<VideoApiAdapter[]> => {
+  const videoAdapters: VideoApiAdapter[] = [];
+
+  for (const cred of withCredentials) {
     const appName = cred.type.split("_").join(""); // Transform `zoom_video` to `zoomvideo`;
-    const app = appStore[appName as keyof typeof appStore];
+    const app = await appStore[appName as keyof typeof appStore];
+
     if (app && "lib" in app && "VideoApiAdapter" in app.lib) {
       const makeVideoApiAdapter = app.lib.VideoApiAdapter as VideoApiAdapterFactory;
       const videoAdapter = makeVideoApiAdapter(cred);
-      acc.push(videoAdapter);
-      return acc;
+      videoAdapters.push(videoAdapter);
     }
-    return acc;
-  }, []);
+  }
+
+  return videoAdapters;
+};
 
-const getBusyVideoTimes = (withCredentials: CredentialPayload[]) =>
-  Promise.all(getVideoAdapters(withCredentials).map((c) => c?.getAvailability())).then((results) =>
+const getBusyVideoTimes = async (withCredentials: CredentialPayload[]) =>
+  Promise.all((await getVideoAdapters(withCredentials)).map((c) => c?.getAvailability())).then((results) =>
     results.reduce((acc, availability) => acc.concat(availability), [] as (EventBusyDate | undefined)[])
   );
 
@@ -45,7 +49,7 @@ const createMeeting = async (credential: CredentialWithAppName, calEvent: Calend
     );
   }
 
-  const videoAdapters = getVideoAdapters([credential]);
+  const videoAdapters = await getVideoAdapters([credential]);
   const [firstVideoAdapter] = videoAdapters;
   let createdMeeting;
   let returnObject: {
@@ -104,7 +108,7 @@ const updateMeeting = async (
 
   let success = true;
 
-  const [firstVideoAdapter] = getVideoAdapters([credential]);
+  const [firstVideoAdapter] = await getVideoAdapters([credential]);
   const updatedMeeting =
     credential && bookingRef
       ? await firstVideoAdapter?.updateMeeting(bookingRef, calEvent).catch(async (e) => {
@@ -135,9 +139,9 @@ const updateMeeting = async (
   };
 };
 
-const deleteMeeting = (credential: CredentialPayload, uid: string): Promise<unknown> => {
+const deleteMeeting = async (credential: CredentialPayload, uid: string): Promise<unknown> => {
   if (credential) {
-    const videoAdapter = getVideoAdapters([credential])[0];
+    const videoAdapter = (await getVideoAdapters([credential]))[0];
     // There are certain video apps with no video adapter defined. e.g. riverby,whereby
     if (videoAdapter) {
       return videoAdapter.deleteMeeting(uid);
@@ -155,7 +159,7 @@ const createMeetingWithCalVideo = async (calEvent: CalendarEvent) => {
   } catch (e) {
     return;
   }
-  const [videoAdapter] = getVideoAdapters([
+  const [videoAdapter] = await getVideoAdapters([
     {
       id: 0,
       appId: "daily-video",
@@ -178,7 +182,7 @@ const getRecordingsOfCalVideoByRoomName = async (
     console.error("Error: Cal video provider is not installed.");
     return;
   }
-  const [videoAdapter] = getVideoAdapters([
+  const [videoAdapter] = await getVideoAdapters([
     {
       id: 0,
       appId: "daily-video",
@@ -199,7 +203,7 @@ const getDownloadLinkOfCalVideoByRecordingId = async (recordingId: string) => {
     console.error("Error: Cal video provider is not installed.");
     return;
   }
-  const [videoAdapter] = getVideoAdapters([
+  const [videoAdapter] = await getVideoAdapters([
     {
       id: 0,
       appId: "daily-video",
diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.ts
index 679d8bd452..dd87a161a0 100644
--- a/packages/features/bookings/lib/handleCancelBooking.ts
+++ b/packages/features/bookings/lib/handleCancelBooking.ts
@@ -240,7 +240,7 @@ async function handler(req: CustomRequest) {
               integrationsToDelete.push(deleteMeeting(credential, reference.uid));
             }
             if (reference.type.includes("_calendar")) {
-              const calendar = getCalendar(credential);
+              const calendar = await getCalendar(credential);
               if (calendar) {
                 integrationsToDelete.push(
                   calendar?.deleteEvent(reference.uid, evt, reference.externalCalendarId)
@@ -262,7 +262,7 @@ async function handler(req: CustomRequest) {
               );
             }
             if (reference.type.includes("_calendar")) {
-              const calendar = getCalendar(credential);
+              const calendar = await getCalendar(credential);
               if (calendar) {
                 integrationsToDelete.push(
                   calendar?.updateEvent(reference.uid, updatedEvt, reference.externalCalendarId)
@@ -449,7 +449,7 @@ async function handler(req: CustomRequest) {
         (credential) => credential.id === credentialId
       );
       if (calendarCredential) {
-        const calendar = getCalendar(calendarCredential);
+        const calendar = await getCalendar(calendarCredential);
         if (
           bookingToDelete.eventType?.recurringEvent &&
           bookingToDelete.recurringEventId &&
@@ -458,7 +458,7 @@ async function handler(req: CustomRequest) {
           bookingToDelete.user.credentials
             .filter((credential) => credential.type.endsWith("_calendar"))
             .forEach(async (credential) => {
-              const calendar = getCalendar(credential);
+              const calendar = await getCalendar(credential);
               for (const updBooking of updatedBookings) {
                 const bookingRef = updBooking.references.find((ref) => ref.type.includes("_calendar"));
                 if (bookingRef) {
@@ -474,12 +474,13 @@ async function handler(req: CustomRequest) {
       }
     } else {
       // For bookings made before the refactor we go through the old behaviour of running through each calendar credential
-      bookingToDelete.user.credentials
-        .filter((credential) => credential.type.endsWith("_calendar"))
-        .forEach((credential) => {
-          const calendar = getCalendar(credential);
-          apiDeletes.push(calendar?.deleteEvent(uid, evt, externalCalendarId) as Promise<unknown>);
-        });
+      const calendarCredentials = bookingToDelete.user.credentials.filter((credential) =>
+        credential.type.endsWith("_calendar")
+      );
+      for (const credential of calendarCredentials) {
+        const calendar = await getCalendar(credential);
+        apiDeletes.push(calendar?.deleteEvent(uid, evt, externalCalendarId) as Promise<unknown>);
+      }
     }
   }
 
@@ -585,7 +586,7 @@ async function handler(req: CustomRequest) {
     }
 
     // Posible to refactor TODO:
-    const paymentApp = appStore[paymentAppCredential?.app?.dirName as keyof typeof appStore];
+    const paymentApp = await appStore[paymentAppCredential?.app?.dirName as keyof typeof appStore];
     if (!(paymentApp && "lib" in paymentApp && "PaymentService" in paymentApp.lib)) {
       console.warn(`payment App service of type ${paymentApp} is not implemented`);
       return null;
diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts
index 9776737003..9fe941e75a 100644
--- a/packages/features/bookings/lib/handleNewBooking.ts
+++ b/packages/features/bookings/lib/handleNewBooking.ts
@@ -885,7 +885,7 @@ async function handler(
               integrationsToDelete.push(deleteMeeting(credential, reference.uid));
             }
             if (reference.type.includes("_calendar") && originalBookingEvt) {
-              const calendar = getCalendar(credential);
+              const calendar = await getCalendar(credential);
               if (calendar) {
                 integrationsToDelete.push(
                   calendar?.deleteEvent(reference.uid, originalBookingEvt, reference.externalCalendarId)
diff --git a/packages/lib/payment/deletePayment.ts b/packages/lib/payment/deletePayment.ts
index b4e1fb4ce7..9afa9b3e54 100644
--- a/packages/lib/payment/deletePayment.ts
+++ b/packages/lib/payment/deletePayment.ts
@@ -13,7 +13,7 @@ const deletePayment = async (
     } | null;
   }
 ): Promise<boolean> => {
-  const paymentApp = appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore];
+  const paymentApp = await appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore];
   if (!(paymentApp && "lib" in paymentApp && "PaymentService" in paymentApp.lib)) {
     console.warn(`payment App service of type ${paymentApp} is not implemented`);
     return false;
diff --git a/packages/lib/payment/handlePayment.ts b/packages/lib/payment/handlePayment.ts
index dcded8e6e8..ff65249a07 100644
--- a/packages/lib/payment/handlePayment.ts
+++ b/packages/lib/payment/handlePayment.ts
@@ -23,7 +23,7 @@ const handlePayment = async (
     uid: string;
   }
 ) => {
-  const paymentApp = appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore];
+  const paymentApp = await appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore];
   if (!(paymentApp && "lib" in paymentApp && "PaymentService" in paymentApp.lib)) {
     console.warn(`payment App service of type ${paymentApp} is not implemented`);
     return null;
diff --git a/packages/trpc/server/routers/viewer/bookings.tsx b/packages/trpc/server/routers/viewer/bookings.tsx
index 8292e1bc13..e4c34cd97f 100644
--- a/packages/trpc/server/routers/viewer/bookings.tsx
+++ b/packages/trpc/server/routers/viewer/bookings.tsx
@@ -550,10 +550,10 @@ export const bookingsRouter = router({
         const bookingRefsFiltered: BookingReference[] = bookingToReschedule.references.filter(
           (ref) => !!credentialsMap.get(ref.type)
         );
-        bookingRefsFiltered.forEach((bookingRef) => {
+        bookingRefsFiltered.forEach(async (bookingRef) => {
           if (bookingRef.uid) {
             if (bookingRef.type.endsWith("_calendar")) {
-              const calendar = getCalendar(credentialsMap.get(bookingRef.type));
+              const calendar = await getCalendar(credentialsMap.get(bookingRef.type));
 
               return calendar?.deleteEvent(
                 bookingRef.uid,
@@ -964,7 +964,7 @@ export const bookingsRouter = router({
             }
 
             // Posible to refactor TODO:
-            const paymentApp = appStore[paymentAppCredential?.app?.dirName as keyof typeof appStore];
+            const paymentApp = await appStore[paymentAppCredential?.app?.dirName as keyof typeof appStore];
             if (!(paymentApp && "lib" in paymentApp && "PaymentService" in paymentApp.lib)) {
               console.warn(`payment App service of type ${paymentApp} is not implemented`);
               return null;

Leaderboard for this case

easy · 9 of 9 bots fully caught it (100% solve rate) · 100% avg coverage.

#BotResultCaughtCoverageFindingsFalse alarms
1 cursor solved 1/1 100.0% 1 0
2 Drape (Deep Review) solved 1/1 100.0% 4 0
3 Drape (Review) solved 1/1 100.0% 2 0
4 greptile solved 1/1 100.0% 2 0
5 Mjolnir (Opus 5.5) solved 1/1 100.0% 3 0
6 Mjolnir (Sonnet 5.5) solved 1/1 100.0% 1 0
7 qodo solved 1/1 100.0% 3 0
8 Claude Code (Opus 5.5) solved 1/1 100.0% 5 1
9 Cubic solved 1/1 100.0% 5 1

Bot results

Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ exact
valid · impact low
The import() calls sit in the object literal, so they all run when the module is evaluated. Nothing is lazy, yet every caller now has to await. If a module fails to load, the rejected promise has no handler until some code awaits that key. The claim is accurate, but the practical impact is limited. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
Before this change, a synchronous throw from getCalendar was caught by the surrounding try/catch. With the async callback it becomes an unhandled rejection that the handler never sees. deleteEvent and deleteMeeting were already fire-and-forget before the change, but the getCalendar path is a new regression. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
valid · impact low
wipemycalother has the same issue: the try/catch no longer catches errors from the awaited getCalendar inside the async forEach callback. [grounded: tree packages/app-store/wipemycalother/lib/reschedule.ts] [consensus 3/3: valid=3]
invalid
The type is inferred from getCalendar, so it does become a Promise. The function has three callers (in calendar.ts and viewer.tsx), and all of them pass the result straight to getConnectedCalendars. That function awaits each calendar promise right away inside its map callback, so the null check works and every rejection gets a handler. [invalid: contradiction] [consensus 3/3: invalid=3]
raw comments (5)
packages/app-store/index.ts:3
The `import("./x")` calls sit inside the object literal, so all ~28 app modules start loading as soon as `@calcom/app-store` is imported. Nothing is deferred, so the change gets none of the lazy-loading benefit it seems to be after, yet every caller now has to await. Any one module that fails to load becomes a promise rejection that only surfaces when some code awaits that key; until then it is unhandled, and current Node versions crash the process on unhandled rejections. To make loading lazy, the values should be thunks such as `applecalendar: () => import("./applecalendar")`, with call sites invoking them.
packages/trpc/server/routers/viewer/bookings.tsx:553
The `forEach` callback is now `async`, so the calendar and video deletions (`getCalendar` → `deleteEvent`, `deleteMeeting`) are never awaited. The handler moves on to send the reschedule-request email and return while the deletions are still running. Any error from `getCalendar` or `deleteEvent` becomes an unhandled promise rejection instead of a failure the handler can see or report. Use `for...of` with `await`, or `Promise.all(bookingRefsFiltered.map(...))`.
packages/app-store/vital/lib/reschedule.ts:125
This change turned the `forEach` callback `async`. The surrounding `try/catch`, which is meant to log errors from deleting calendar events and meetings, now catches nothing: errors from `getCalendar`, `deleteEvent` and `deleteMeeting` become unhandled rejections. Execution also no longer waits for the deletions before continuing. Use `for...of` with `await`, or `await Promise.all(...)`.
packages/app-store/wipemycalother/lib/reschedule.ts:125
Same problem as in the vital reschedule: the new `async` `forEach` callback means the `try/catch` no longer catches errors from `getCalendar`, `deleteEvent` or `deleteMeeting`, so they surface as unhandled rejections. The deletions are also fire-and-forget and run alongside the rest of the reschedule flow.
packages/core/CalendarManager.ts:28
`getCalendarCredentials` now puts a `Promise<Calendar | null>` in the `calendar` field without awaiting it or changing its declared shape. `getConnectedCalendars` awaits it, but any other consumer of `.calendar` gets a promise that is always truthy, so a null check would pass wrongly. If a calendar ends up unused, a rejection from it is never handled. Better to await inside `getCalendarCredentials` or make the async type explicit.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ off by one
valid · matches d3 · impact medium
valid · impact medium
The diff makes the forEach callback async and adds `await getCalendar(...)` inside it. Nothing awaits these promises, and errors from getCalendar now escape the surrounding try/catch as unhandled rejections. The deletes were already fire-and-forget before this change, but the change makes the error handling worse. [grounded: diff] [consensus 5/5: valid=5]
valid · impact medium
The diff makes the forEach callback async in the requestReschedule mutation. Nothing awaits these promises, so getCalendar and delete failures become unhandled rejections and the handler continues without waiting for them. [grounded: diff] [consensus 5/5: valid=5]
invalid
In the recurring-cancel branch, `.forEach(async (credential) =>` is an unchanged context line. The callback was already async before this change, and `apiDeletes.push` already ran after an await on deleteEvent. The only edit there was adding await to getCalendar, so this problem existed before the PR. [invalid: contradiction] [consensus 5/5: invalid=5]
valid · impact low
Every import() in the object literal starts as soon as the module is evaluated, so the new code does not lazy-load integrations as intended. The previous static imports also loaded everything, so this is not a runtime regression; it is a refactor that does not achieve its goal. [grounded: diff] [consensus 4/5: valid=4, invalid=1]
raw comments (6)
packages/app-store/wipemycalother/lib/reschedule.ts:125
<!-- cubic:v=f405fc81-dc1f-41cf-a72e-34215115dda0 --> <!-- cubic:review-run=e8a987ed-d84d-55cf-9790-292c204a444f --> <!-- metadata:{"confidence":10} --> P1: When a reschedule has a calendar reference, `forEach` discards the async callback promise, so the function sends the reschedule email and returns before `getCalendar`/`deleteEvent` finishes; rejected deletions also bypass this `try/catch`. Await a `Promise.all` over the references (or use a `for...of` loop) so cleanup completes and errors are handled before continuing. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/app-store/wipemycalother/lib/reschedule.ts, line 125: <comment>When a reschedule has a calendar reference, `forEach` discards the async callback promise, so the function sends the reschedule email and returns before `getCalendar`/`deleteEvent` finishes; rejected deletions also bypass this `try/catch`. Await a `Promise.all` over the references (or use a `for...of` loop) so cleanup completes and errors are handled before continuing.</comment> <file context> @@ -122,10 +122,10 @@ const Reschedule = async (bookingUid: string, cancellationReason: string) => { ); try { - bookingRefsFiltered.forEach((bookingRef) => { + bookingRefsFiltered.forEach(async (bookingRef) => { if (bookingRef.uid) { if (bookingRef.type.endsWith("_calendar")) { </file context> ``` </details>
packages/app-store/vital/lib/reschedule.ts:131
<!-- cubic:v=1cb7956d-e4ce-4674-b57b-c376ba885205 --> <!-- cubic:review-run=e8a987ed-d84d-55cf-9790-292c204a444f --> <!-- metadata:{"confidence":10} --> P1: The async callback is not awaited, so rescheduling can send its email and return before calendar/video cancellation finishes; cleanup failures also bypass this `try/catch` and become unhandled rejections. Await the mapped cleanup promises before continuing. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/app-store/vital/lib/reschedule.ts, line 125: <comment>The async callback is not awaited, so rescheduling can send its email and return before calendar/video cancellation finishes; cleanup failures also bypass this `try/catch` and become unhandled rejections. Await the mapped cleanup promises before continuing.</comment> <file context> @@ -122,10 +122,10 @@ const Reschedule = async (bookingUid: string, cancellationReason: string) => { ); try { - bookingRefsFiltered.forEach((bookingRef) => { + bookingRefsFiltered.forEach(async (bookingRef) => { if (bookingRef.uid) { if (bookingRef.type.endsWith("_calendar")) { </file context> ``` </details>
packages/trpc/server/routers/viewer/bookings.tsx:559
<!-- cubic:v=d6df6f56-049f-40c3-958a-10264a4f12cd --> <!-- cubic:review-run=e8a987ed-d84d-55cf-9790-292c204a444f --> <!-- metadata:{"confidence":10} --> P1: When a rescheduled booking has integration references, this `forEach` does not await its async callback. The handler can return before calendar/video cancellation finishes, and deletion failures become unhandled; await `Promise.all(bookingRefsFiltered.map(...))` instead. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/bookings.tsx, line 553: <comment>When a rescheduled booking has integration references, this `forEach` does not await its async callback. The handler can return before calendar/video cancellation finishes, and deletion failures become unhandled; await `Promise.all(bookingRefsFiltered.map(...))` instead.</comment> <file context> @@ -550,10 +550,10 @@ export const bookingsRouter = router({ (ref) => !!credentialsMap.get(ref.type) ); - bookingRefsFiltered.forEach((bookingRef) => { + bookingRefsFiltered.forEach(async (bookingRef) => { if (bookingRef.uid) { if (bookingRef.type.endsWith("_calendar")) { </file context> ``` </details>
packages/features/bookings/lib/handleCancelBooking.ts:243
<!-- cubic:v=a4d10247-3c4e-477b-b517-e7f8c48d05cc --> <!-- cubic:review-run=e8a987ed-d84d-55cf-9790-292c204a444f --> <!-- metadata:{"confidence":9} --> P1: When cancelling all instances of a recurring booking, this async `forEach` is not awaited. The handler can finish with `apiDeletes` still empty, leaving calendar events undeleted and callback failures unhandled; use an awaited `for...of` loop or collect and await the callback promises. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/features/bookings/lib/handleCancelBooking.ts, line 243: <comment>When cancelling all instances of a recurring booking, this async `forEach` is not awaited. The handler can finish with `apiDeletes` still empty, leaving calendar events undeleted and callback failures unhandled; use an awaited `for...of` loop or collect and await the callback promises.</comment> <file context> @@ -240,7 +240,7 @@ async function handler(req: CustomRequest) { } if (reference.type.includes("_calendar")) { - const calendar = getCalendar(credential); + const calendar = await getCalendar(credential); if (calendar) { integrationsToDelete.push( </file context> ``` </details>
packages/app-store/index.ts:3
<!-- cubic:v=e29a40a4-a158-4e70-ab5b-e464666b2d5a --> <!-- cubic:review-run=e8a987ed-d84d-55cf-9790-292c204a444f --> <!-- metadata:{"confidence":9} --> P2: When any caller imports `@calcom/app-store`, this initializer immediately starts every integration import before the requested key is known, so the store is not lazy and cold starts load all integrations. Move each `import()` behind a loader function or accessor so only the selected integration is started. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/app-store/index.ts, line 3: <comment>When any caller imports `@calcom/app-store`, this initializer immediately starts every integration import before the requested key is known, so the store is not lazy and cold starts load all integrations. Move each `import()` behind a loader function or accessor so only the selected integration is started.</comment> <file context> @@ -1,63 +1,33 @@ - exchangecalendar, - facetime, + // example: import("./example"), + applecalendar: import("./applecalendar"), + caldavcalendar: import("./caldavcalendar"), + closecom: import("./closecom"), </file context> ``` </details>
PR-level
<!-- cubic:review-summary:start --> **5 issues found** across 12 files <!-- cubic:review-summary:end --> <details> <summary>Prompt for AI agents (unresolved issues)</summary> ```text Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately. <file name="packages/app-store/wipemycalother/lib/reschedule.ts"> <violation number="1" location="packages/app-store/wipemycalother/lib/reschedule.ts:125"> P1: When a reschedule has a calendar reference, `forEach` discards the async callback promise, so the function sends the reschedule email and returns before `getCalendar`/`deleteEvent` finishes; rejected deletions also bypass this `try/catch`. Await a `Promise.all` over the references (or use a `for...of` loop) so cleanup completes and errors are handled before continuing.</violation> </file> <file name="packages/app-store/vital/lib/reschedule.ts"> <violation number="1" location="packages/app-store/vital/lib/reschedule.ts:125"> P1: The async callback is not awaited, so rescheduling can send its email and return before calendar/video cancellation finishes; cleanup failures also bypass this `try/catch` and become unhandled rejections. Await the mapped cleanup promises before continuing.</violation> </file> <file name="packages/trpc/server/routers/viewer/bookings.tsx"> <violation number="1" location="packages/trpc/server/routers/viewer/bookings.tsx:553"> P1: When a rescheduled booking has integration references, this `forEach` does not await its async callback. The handler can return before calendar/video cancellation finishes, and deletion failures become unhandled; await `Promise.all(bookingRefsFiltered.map(...))` instead.</violation> </file> <file name="packages/features/bookings/lib/handleCancelBooking.ts"> <violation number="1" location="packages/features/bookings/lib/handleCancelBooking.ts:243"> P1: When cancelling all instances of a recurring booking, this async `forEach` is not awaited. The handler can finish with `apiDeletes` still empty, leaving calendar events undeleted and callback failures unhandled; use an awaited `for...of` loop or collect and await the callback promises.</violation> </file> <file name="packages/app-store/index.ts"> <violation number="1" location="packages/app-store/index.ts:3"> P2: When any caller imports `@calcom/app-store`, this initializer immediately starts every integration import before the requested key is known, so the store is not lazy and cold starts load all integrations. Move each `import()` behind a loader function or accessor so only the selected integration is started.</violation> </file> ``` </details> <sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/24/ai_pr_review_github_delivery_2c0db9ba221ee41d0ad6ca809d3e537135aed69a789a88fd3d9d6039ffbbcd9f?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F24)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_2c0db9ba221ee41d0ad6ca809d3e537135aed69a789a88fd3d9d6039ffbbcd9f:e01d57831e89d6c5df7a35aa31942f91514117ee:e8a987ed-d84d-55cf-9790-292c204a444f -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ off by one
valid · matches d3 · impact medium
raw comments (2)
packages/trpc/server/routers/viewer/bookings.tsx:556
### Reschedule skips calendar event deletion **High Severity** <!-- DESCRIPTION START --> `getCalendar` is now async, but these reschedule paths call it inside `forEach(async …)`, which does not wait. Calendar and video deletions can start after the handler continues (emails, response), so they may never finish on serverless. Surrounding `try/catch` also no longer sees rejections from `getCalendar`. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 4ddf6e9d-d5e9-44e2-917a-872f4ef89e2b --> <!-- LOCATIONS START packages/trpc/server/routers/viewer/bookings.tsx#L552-L567 packages/app-store/vital/lib/reschedule.ts#L124-L134 packages/app-store/wipemycalother/lib/reschedule.ts#L124-L134 LOCATIONS END --> <details> <summary>Additional Locations (2)</summary> - [`packages/app-store/vital/lib/reschedule.ts#L124-L134`](https://github.com/drape-io/crbench-cursor-2026-09/blob/89637136b8df7780489c5ac8c07a308b6d253e20/packages/app-store/vital/lib/reschedule.ts#L124-L134) - [`packages/app-store/wipemycalother/lib/reschedule.ts#L124-L134`](https://github.com/drape-io/crbench-cursor-2026-09/blob/89637136b8df7780489c5ac8c07a308b6d253e20/packages/app-store/wipemycalother/lib/reschedule.ts#L124-L134) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjMxYzQ0M2RmLTZkY2QtNDQzMC05ZmUzLTVkNzUxMTAyNDMwZSIsImVuY3J5cHRpb25LZXkiOiIzaHp6V3IxdDBOLVVsbXJNeWZ1MmFhMVNpUE1GbWdsdkRqeTdxSDl1UE4wIiwiYnJhbmNoIjoidDItY2FsLWNvbS04MDg3IiwicmVwb093bmVyIjoiZHJhcGUtaW8iLCJyZXBvTmFtZSI6ImNyYmVuY2gtY3Vyc29yLTIwMjYtMDkiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjMxYzQ0M2RmLTZkY2QtNDQzMC05ZmUzLTVkNzUxMTAyNDMwZSIsImVuY3J5cHRpb25LZXkiOiIzaHp6V3IxdDBOLVVsbXJNeWZ1MmFhMVNpUE1GbWdsdkRqeTdxSDl1UE4wIiwiYnJhbmNoIjoidDItY2FsLWNvbS04MDg3IiwicmVwb093bmVyIjoiZHJhcGUtaW8iLCJyZXBvTmFtZSI6ImNyYmVuY2gtY3Vyc29yLTIwMjYtMDkiLCJwck51bWJlciI6MjUsImNvbW1pdFNoYSI6Ijg5NjM3MTM2YjhkZjc3ODA0ODljNWFjOGMwN2EzMDhiNmQyNTNlMjAiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 89637136b8df7780489c5ac8c07a308b6d253e20. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTo0ZGQ1NjM4Mi04OWI5LTQwZWYtYTA2OS0yMjVhM2UxYTJkMGYiLCJlbmNyeXB0aW9uS2V5IjoiNlBPeUM5LWpfM2dTb1I3cEJMUGFIM3JCU084RlZiNDJwM01CUEpYQkNONCIsImJyYW5jaCI6InQyLWNhbC1jb20tODA4NyIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 89637136b8df7780489c5ac8c07a308b6d253e20. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ exact
valid · matches d3 · impact medium
valid · impact low
Before the change, getCalendar ran synchronously inside forEach, so a throw (for example from the CalendarService constructor) failed the mutation. Now it runs inside an async callback that nothing awaits, so the failure becomes an unhandled rejection and sendRequestRescheduleEmail still runs. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
getCalendar is now async and is called for every credential. For non-calendar variants the returned promise is thrown away and never awaited, so a rejection goes unhandled. Before, the same failure was a synchronous throw. Only the calendar-variant promises are awaited later, inside getConnectedCalendars. [grounded: tree packages/core/CalendarManager.ts] [consensus 3/3: valid=3]
valid · impact low
Each import() runs when the object literal is evaluated, so every app still loads when the module is imported. A failed load has no handler until some later lookup awaits it, so it becomes an unhandled rejection. Before, the static imports would have failed the module load outright. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
packages/app-store/wipemycalother/lib/reschedule.ts:125
**Calendar errors escape the reschedule try/catch** The `forEach` callback is now async, so errors thrown by `getCalendar` or `deleteMeeting` become rejected promises. The surrounding try/catch never sees them, and they end up as unhandled rejections. Use a for...of loop with await inside the try block. The same mistake is at `packages/app-store/vital/lib/reschedule.ts:125`. ``` packages/app-store/wipemycalother/lib/reschedule.ts:125 bookingRefsFiltered.forEach(async (bookingRef) => { packages/app-store/wipemycalother/lib/reschedule.ts:126 if (bookingRef.uid) { packages/app-store/wipemycalother/lib/reschedule.ts:127 if (bookingRef.type.endsWith("_calendar")) { packages/app-store/wipemycalother/lib/reschedule.ts:128 const calendar = await getCalendar(credentialsMap.get(bookingRef.type)); packages/app-store/wipemycalother/lib/reschedule.ts:124 try { packages/app-store/wipemycalother/lib/reschedule.ts:129 return calendar?.deleteEvent(bookingRef.uid, builder.calendarEvent); packages/app-store/wipemycalother/lib/reschedule.ts:130 } else if (bookingRef.type.endsWith("_video")) { packages/app-store/wipemycalother/lib/reschedule.ts:131 return deleteMeeting(credentialsMap.get(bookingRef.type), bookingRef.uid); packages/app-store/wipemycalother/lib/reschedule.ts:132 } packages/app-store/wipemycalother/lib/reschedule.ts:133 } ```
packages/trpc/server/routers/viewer/bookings.tsx:553
**requestReschedule swallows calendar setup errors** With an async `forEach` callback, a throw from `getCalendar` no longer fails the mutation. It becomes an unhandled rejection, and the reschedule emails go out anyway. Await the deletions with Promise.all over a map, or use a for...of loop. ``` packages/trpc/server/routers/viewer/bookings.tsx:553 bookingRefsFiltered.forEach(async (bookingRef) => { packages/trpc/server/routers/viewer/bookings.tsx:554 if (bookingRef.uid) { packages/trpc/server/routers/viewer/bookings.tsx:555 if (bookingRef.type.endsWith("_calendar")) { packages/trpc/server/routers/viewer/bookings.tsx:556 const calendar = await getCalendar(credentialsMap.get(bookingRef.type)); packages/trpc/server/routers/viewer/bookings.tsx:558 return calendar?.deleteEvent( packages/trpc/server/routers/viewer/bookings.tsx:559 bookingRef.uid, packages/trpc/server/routers/viewer/bookings.tsx:560 builder.calendarEvent, packages/trpc/server/routers/viewer/bookings.tsx:561 bookingRef.externalCalendarId packages/trpc/server/routers/viewer/bookings.tsx:562 ); packages/trpc/server/routers/viewer/bookings.tsx:563 } else if (bookingRef.type.endsWith("_video")) { ```
packages/core/CalendarManager.ts:28
**Calendar created for non-calendar variants and never awaited** `getCalendarCredentials` calls the now-async `getCalendar` for every credential, including ones whose app variant isn't "calendar". Those promises are thrown away without being awaited, so if one rejects nothing handles it. Only call getCalendar when app.variant === "calendar". ``` packages/core/CalendarManager.ts:28 const calendar = getCalendar(credential); packages/core/CalendarManager.ts:29 return app.variant === "calendar" ? [{ integration: app, credential, calendar }] : []; packages/app-store/_utils/getCalendar.ts:9 export const getCalendar = async (credential: CredentialPayload | null): Promise<Calendar | null> => { packages/app-store/_utils/getCalendar.ts:10 if (!credential || !credential.key) return null; packages/core/CalendarManager.ts:27 const credentials = app.credentials.flatMap((credential) => { packages/core/CalendarManager.ts:30 }); ```
packages/app-store/index.ts:4
**App modules still load eagerly at import** Each import() runs when the appStore object is built, so importing this file loads every app, and a failed load nobody awaits becomes an unhandled rejection. Make entries thunks like () => import("./x") and call them at lookup. ``` packages/app-store/index.ts:1 const appStore = { packages/app-store/index.ts:2 // example: import("./example"), packages/app-store/index.ts:3 applecalendar: import("./applecalendar"), packages/app-store/index.ts:4 caldavcalendar: import("./caldavcalendar"), packages/app-store/index.ts:5 closecom: import("./closecom"), packages/app-store/index.ts:6 dailyvideo: import("./dailyvideo"), packages/app-store/index.ts:7 googlecalendar: import("./googlecalendar"), packages/app-store/index.ts:8 googlevideo: import("./googlevideo"), packages/app-store/index.ts:9 hubspot: import("./hubspot"), packages/app-store/index.ts:10 huddle01video: import("./huddle01video"), ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ off by one
valid · matches d3 · impact medium
valid · impact low
The new object literal calls import() for every app as soon as the module is evaluated, so every app module still loads at startup and nothing is deferred. A module that fails to load leaves a rejected promise with no handler until some caller awaits that key, which is an unhandled rejection. Before this change, the same failure was a synchronous import error instead. The behaviour is real, but the practical impact is limited. [grounded: tree packages/app-store/index.ts] [consensus 3/3: valid=3]
raw comments (2)
packages/app-store/vital/lib/reschedule.ts:125
**Calendar setup errors escape the try/catch** With the callback now async and awaiting getCalendar, a throw while building the calendar (for example, a CalendarService constructor failing to decrypt or parse the credential key) is no longer caught and logged. It becomes an unhandled rejection. Await the work with Promise.all over a map inside the try. The same mistake is at `packages/app-store/wipemycalother/lib/reschedule.ts:125` and `packages/trpc/server/routers/viewer/bookings.tsx:553`. ``` packages/app-store/vital/lib/reschedule.ts:125 bookingRefsFiltered.forEach(async (bookingRef) => { packages/app-store/vital/lib/reschedule.ts:126 if (bookingRef.uid) { packages/app-store/vital/lib/reschedule.ts:127 if (bookingRef.type.endsWith("_calendar")) { packages/app-store/vital/lib/reschedule.ts:128 const calendar = await getCalendar(credentialsMap.get(bookingRef.type)); ```
packages/app-store/index.ts:1
**All app imports still run eagerly at load** The object literal calls import() for every app as soon as the module loads, so nothing is lazy. An app module that throws while loading leaves a rejected promise with no handler: an unhandled rejection at startup. Store loader functions (() => import("./x")) and call them on use. ``` packages/app-store/index.ts:1 const appStore = { packages/app-store/index.ts:2 // example: import("./example"), packages/app-store/index.ts:3 applecalendar: import("./applecalendar"), packages/app-store/index.ts:4 caldavcalendar: import("./caldavcalendar"), ```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ off by one
valid · impact medium
The finding holds. In the new `appStore` object, each property is a bare `import("./x")` call, and those calls run as soon as the object is built. Importing the index therefore starts loading all 29 integrations at once, so the PR's lazy-loading goal isn't met even though every consumer now has to await. This PR introduced the pattern. Wrapping each entry in a function, such as `() => import("./x")`, and calling only the needed one would make the loading lazy. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
raw comments (2)
packages/app-store/index.ts:30
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> **Dynamic imports remain eager** Every `import()` runs while `appStore` is constructed, so importing this index immediately starts loading all 29 integrations rather than only the selected one. This keeps the eager loading cost while forcing consumers onto asynchronous APIs and, in chunked builds, can request every integration at startup. Store import functions such as `() => import("./applecalendar")` and invoke only the requested entry. Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
PR-level
<h3>Greptile Summary</h3> This PR changes the app-store registry from static module namespaces to dynamic-import promises and updates calendar, video, and payment consumers to await integration loading. - Updates calendar construction and CalendarManager/EventManager call sites for asynchronous loading. - Makes video-adapter and payment-service lookup asynchronous. - Introduces detached cleanup operations in rescheduling and recurring cancellation flows. - Starts all dynamic imports eagerly despite the new asynchronous interface. <h3>Confidence Score: 3/5</h3> This PR is not safe to merge until reschedule and recurring-cancellation cleanup operations are properly awaited. Two distinct booking flows can report success and continue destructive or user-visible work before required external calendar cleanup finishes, while cleanup failures escape their intended error handling; the app registry also initiates every dynamic import eagerly. **Files Needing Attention:** packages/trpc/server/routers/viewer/bookings.tsx, packages/features/bookings/lib/handleCancelBooking.ts, packages/app-store/vital/lib/reschedule.ts, packages/app-store/wipemycalother/lib/reschedule.ts, packages/app-store/index.ts <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | packages/app-store/index.ts | Replaces static app namespaces with eagerly initiated dynamic-import promises. | | packages/app-store/_utils/getCalendar.ts | Makes calendar service resolution asynchronous and awaits the selected app-store entry. | | packages/core/CalendarManager.ts | Propagates asynchronous calendar resolution through calendar connection and event operations. | | packages/core/videoClient.ts | Makes video-adapter lookup asynchronous and updates its consumers. | | packages/trpc/server/routers/viewer/bookings.tsx | Updates service lookups but detaches asynchronous cleanup during rescheduling. | | packages/features/bookings/lib/handleCancelBooking.ts | Updates calendar/payment lookup while breaking synchronization of recurring external-calendar cleanup. | | packages/app-store/vital/lib/reschedule.ts | Introduces detached asynchronous calendar cleanup before reporting reschedule success. | | packages/app-store/wipemycalother/lib/reschedule.ts | Duplicates the detached asynchronous cleanup regression in the alternate reschedule integration. | </details> <details open><summary><h3>Flowchart</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD A[Reschedule or recurring cancellation] --> B[forEach invokes async callback] B --> C[Callback pauses at await getCalendar] B --> D[Enclosing handler continues] D --> E[Send email / mutate database / return success] C --> F[Delete or update external event] F --> G{Operation fails?} G -->|Yes| H[Detached rejection] G -->|No| I[Cleanup completes after handler advanced] ``` </details> <!-- greptile_failed_comments --> <details><summary><h3>Comments Outside Diff (2)</h3></summary> 1. `packages/trpc/server/routers/viewer/bookings.tsx`, line 553-567 ([link](https://github.com/drape-io/crbench-greptile-2026-09/blob/7c9dae8f43a95423a2e9ab3fad19dfbab2cf9c0d/packages/trpc/server/routers/viewer/bookings.tsx#L553-L567)) <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Cleanup promises are detached** `Array.forEach` ignores the promises returned by these async callbacks. The handler sends the reschedule email and continues before the old calendar event or video meeting is deleted, and a failed calendar lookup or deletion becomes an unhandled rejection instead of failing the reschedule. Await the cleanup operations with `Promise.all` or an awaited loop. The same regression appears in `packages/app-store/vital/lib/reschedule.ts:125-134` and `packages/app-store/wipemycalother/lib/reschedule.ts:125-134`. 2. `packages/features/bookings/lib/handleCancelBooking.ts`, line 458-470 ([link](https://github.com/drape-io/crbench-greptile-2026-09/blob/7c9dae8f43a95423a2e9ab3fad19dfbab2cf9c0d/packages/features/bookings/lib/handleCancelBooking.ts#L458-L470)) <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Recurring cleanup is not awaited** This loop awaits `getCalendar` and `deleteEvent` inside an unawaited `forEach` callback, so the later `Promise.all(apiDeletes)` can begin before these operations are added. The handler can delete booking data, send cancellation mail, and return HTTP 200 while external recurring events remain stale; provider failures are also detached. Collect and await the per-credential operations before continuing. </details> <!-- /greptile_failed_comments --> <sub>Reviews (1): Last reviewed commit: ["Update packages/app-store/\_utils/getCale..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/7c9dae8f43a95423a2e9ab3fad19dfbab2cf9c0d) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64288943)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ off by one
valid · impact low
Each property of the object literal calls `import()` directly, so every module starts loading as soon as `@calcom/app-store` is evaluated. Nothing is lazy, which means the intended deferred loading does not happen. Load cost is no worse than the old static imports, so the impact is low. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
Before the change, `getCalendar` (including the CalendarService constructor) ran synchronously inside the try block, so its errors were caught. It now runs in an async forEach callback whose promise is dropped, so any error becomes an unhandled rejection that the surrounding try/catch never sees. The same change appears in vital, wipemycalother and bookings.tsx. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
raw comments (3)
packages/app-store/index.ts:4
[P3] Dynamic imports run immediately, so nothing is lazy-loaded Each property is written as `import("./x")`, so all 28 app modules start loading as soon as `@calcom/app-store` is imported, before any caller needs them. Every consumer (videoClient, handlePayment, getCalendar, and so on) still pulls in the whole app store on first import. The change only makes each lookup async and does not cut load time or memory. To load an app only when it is used, each entry would need to be a thunk such as `applecalendar: () =› import("./applecalendar")`, with callers doing `await appStore[key]?.()`.
packages/app-store/vital/lib/reschedule.ts:125
[P3] getCalendar errors inside `forEach(async …)` are no longer caught Moving `getCalendar` into an async `forEach` callback means the surrounding `try/catch` no longer catches its errors, for example when a CalendarService constructor throws on a bad credential key. Before, those errors were thrown synchronously and caught. Now they become unhandled promise rejections that `forEach` drops, so the catch block's handling is skipped, and with Node's default settings this can crash the process. The same pattern was added in `packages/app-store/wipemycalother/lib/reschedule.ts:125-128` and `packages/trpc/server/routers/viewer/bookings.tsx:553-556`. Collecting the promises with `map` and awaiting them inside the `try`, as the `for…of` rewrite in handleCancelBooking does, would keep the old error handling.
packages/app-store/vital/lib/reschedule.ts:125
[P3] Async `forEach` callback bypasses the surrounding try/catch (same pattern in packages/app-store/wipemycalother/lib/reschedule.ts:125-128) The `try { ... } catch { logger.error(...) }` block around this loop was there to log failures from calendar and video cleanup. Before this change, errors raised synchronously inside the callback were caught by it, for example a `CalendarService` constructor throwing on a bad credential key, or an error building the video adapter in `deleteMeeting`. Now the callback is `async` and `getCalendar`/`deleteMeeting` return promises. Nothing awaits those promises, so the same errors become unhandled promise rejections, are not logged through `logger`, and may trigger the process-level unhandled-rejection behaviour. This only matters when a credential's service fails to construct or load. To keep the catch working, use a `for...of` loop with `await`, or `await Promise.all(bookingRefsFiltered.map(async ...))` inside the `try`.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ off by one
valid · matches d3 · impact medium
raw comments (1)
packages/app-store/vital/lib/reschedule.ts:125
[P3] try/catch no longer covers calendar lookup/delete errors (same pattern in packages/app-store/wipemycalother/lib/reschedule.ts:125-128) `forEach` was changed to an `async` callback so it can `await getCalendar(...)`, but `forEach` does not await the returned promises. The surrounding `try { ... } catch (error) { logger.error(...) }` therefore no longer sees anything thrown by `getCalendar` (for example when a `CalendarService` constructor throws). Before this change that throw was synchronous and was caught and logged. Now it becomes an unhandled promise rejection, which can crash the Node process on Node 15+ or be silently dropped, and the code after the loop runs without waiting for the deletes. This only matters when an adapter throws or rejects while resolving or deleting the calendar event. The fix is to collect the promises and `await Promise.all` (or use `for…of` with `await`) inside the `try`. `packages/trpc/server/routers/viewer/bookings.tsx:553-556` has the same fire-and-forget `forEach(async …)` shape.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d3 medium ✓ off by one
valid · matches d3 · impact medium
valid · impact medium
The deletion promise was never awaited before this change either. What is new is that the callback is now async and awaits getCalendar, so deletion now starts after the route has already moved on to sendRequestRescheduleEmail. Errors from getCalendar used to throw synchronously into the route; now they become unhandled rejections. The change made this worse. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
The async forEach was already there, but getCalendar used to be synchronous, so the first deleteEvent started before the handler continued. Awaiting getCalendar now pushes every deletion past the final Promise.all over apiDeletes. That makes the race worse than before. [grounded: diff] [consensus 3/4: valid=3, invalid=1]
raw comments (5)
packages/app-store/vital/lib/reschedule.ts:125
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 1\. Two app reschedules outrun cleanup <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> The Vital and WipeMyCalOther <b><i>Reschedule</i></b> implementations pass an async callback to <b><i>forEach</i></b>, so the newly awaited <b><i>getCalendar</i></b> lookup is detached from the surrounding <b><i>try</i></b> block. When a rescheduled booking has a calendar reference, each function can send its email and return before <b><i>deleteEvent</i></b> starts, while lookup failures bypass the intended catch handler. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Vital and WipeMyCalOther rescheduling launch asynchronous calendar cleanup through `forEach`, which does not await its callback. The enclosing functions can therefore finish before calendar deletion starts, and their `try/catch` blocks do not receive asynchronous failures. ## Fix Focus Areas - packages/app-store/vital/lib/reschedule.ts[124-139] - packages/app-store/wipemycalother/lib/reschedule.ts[124-139] ## Recommended Fix Replace each async `forEach` with an awaited `Promise.all(bookingRefsFiltered.map(...))` or an awaited `for...of` loop. Keep both calendar and video deletion promises inside the awaited operation so the existing error handler covers lookup and cleanup failures. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/trpc/server/routers/viewer/bookings.tsx:553
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 2\. Viewer reschedules outrun cleanup <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> The viewer reschedule route passes an async callback to <b><i>bookingRefsFiltered.forEach</i></b>, leaving the newly awaited calendar lookup outside the route&#x27;s awaited sequence. For calendar-backed bookings, execution reaches <b><i>sendRequestRescheduleEmail</i></b> while the app module is still loading, and lookup or deletion failures are not propagated through the route. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The viewer reschedule path launches calendar and video cleanup through an async `forEach` callback. Calendar cleanup now yields while resolving the app module, allowing the route to send its email and continue without waiting for cleanup or receiving its failures. ## Fix Focus Areas - packages/trpc/server/routers/viewer/bookings.tsx[550-570] ## Recommended Fix Replace the async `forEach` with `await Promise.all(bookingRefsFiltered.map(...))` or an awaited `for...of` loop. Return or await both calendar and video deletion operations so cleanup completes, or fails the request, before the email is sent. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/features/bookings/lib/handleCancelBooking.ts:461
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 3\. Recurring cleanup starts too late <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> The recurring-cancellation branch adds <b><i>await getCalendar</i></b> inside an async <b><i>forEach</i></b> callback whose promise is discarded. When remaining recurring bookings need calendar removal, the handler can reach the final <b><i>Promise.all</i></b> before those lookups resolve, so deletions have not yet been initiated or added to <b><i>apiDeletes</i></b>. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Recurring calendar cleanup pauses at the asynchronous calendar factory inside an unawaited `forEach` callback. The cancellation handler can snapshot `apiDeletes` and finish before those callbacks initiate their deletions. ## Fix Focus Areas - packages/features/bookings/lib/handleCancelBooking.ts[458-470] - packages/features/bookings/lib/handleCancelBooking.ts[650-654] ## Recommended Fix Replace the async `forEach` with an awaited loop or construct deletion promises with nested `flatMap`/`map` calls and await them directly. Do not asynchronously push resolved deletion results into `apiDeletes`; add actual promises before the final `Promise.all`, or complete the recurring cleanup before proceeding. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
PR-level
<h3>PR Summary by Qodo</h3> Load app-store integrations through dynamic imports <code>✨ Enhancement</code> <code>🕐 40+ Minutes</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <details> <summary>AI Description</summary> <dl> <dd> <br/> ><pre> >• Enable split integration loading by replacing static app-store imports with dynamic imports. >• Propagate asynchronous resolution through calendar, video, payment, and booking flows. ></pre> </dd> </dl> </details> <details> <summary>Diagram</summary> <dl> <dd> <br/> ```mermaid graph TD BF["Booking flows"] --> AR["App registry"] --> DI["Dynamic imports"] --> IM["Integration modules"] --> CS["Calendar services"] CM["Core managers"] --> AR IM --> VA["Video adapters"] IM --> PS["Payment services"] ``` </dd> </dl> </details> <details> <summary>High-Level Assessment</summary> <dl> <dd> <br/> >The following are alternative approaches to this PR: <details> <summary><b>1. Loader-function registry</b></summary> <dl> <dd> - ➕ Defers each import until its integration is requested - ➕ Avoids initiating every registered module import when the registry evaluates - ➖ Requires invoking registry entries instead of directly awaiting them - ➖ Introduces broader API and typing changes across consumers </dd> </dl> </details> <details> <summary><b>2. Central asynchronous app resolver</b></summary> <dl> <dd> - ➕ Encapsulates loading, validation, logging, and unsupported-app handling - ➕ Provides one location for caching and import failure observability - ➖ Adds an abstraction beyond the scope of this migration - ➖ Requires all consumers to adopt a new resolver contract </dd> </dl> </details> >**Recommendation:** The promise-based registry is a reasonable minimal migration because it preserves keyed access while enabling asynchronous chunks. Keep this approach for the current PR, but consider loader functions or a central resolver if the goal includes true demand-driven loading, since the current import promises are created as soon as the registry module evaluates. </dd> </dl> </details> <details> <summary> Files changed (12) <code> +82 / -107 </code> </summary> <dl> <dd> <br/> <details> <summary>Enhancement (1) <code> +29 / -59 </code></summary> <dl> <dd> <details> <summary>index.ts<code>Replace static app imports with dynamic import promises</code> <code>+29/-59</code></summary> <br/> >Replace static app imports with dynamic import promises > ><pre> >• Converts the central app-store registry from eagerly imported namespaces to keyed dynamic import promises for all registered integrations. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-8d0187f3e8930f70c4a3baae2905502d659e5bbadcf136e011d792c4ea7487e9'>packages/app-store/index.ts</a> </details> </dd> </dl> </details> <details> <summary>Refactor (11) <code> +53 / -48 </code></summary> <dl> <dd> <details> <summary>getCalendar.ts<code>Resolve calendar integrations asynchronously</code> <code>+2/-2</code></summary> <br/> >Resolve calendar integrations asynchronously > ><pre> >• Makes the calendar factory asynchronous and awaits the selected app module before validating and constructing its CalendarService. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-0ff04f0ebf0d9b5943cfd0a1840aed833062259b3e6111f82f05b252960a8bc8'>packages/app-store/_utils/getCalendar.ts</a> </details> <details> <summary>reschedule.ts<code>Await calendar resolution during Vital rescheduling</code> <code>+2/-2</code></summary> <br/> >Await calendar resolution during Vital rescheduling > ><pre> >• Makes reference callbacks asynchronous so calendar modules resolve before deleting related events during rescheduling. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-45807fe7862f3b75cfbc6a78ca64fcb9b369b41f0230b164d0e19c0ecb3c18c2'>packages/app-store/vital/lib/reschedule.ts</a> </details> <details> <summary>reschedule.ts<code>Await calendar resolution during Wipe My Cal rescheduling</code> <code>+2/-2</code></summary> <br/> >Await calendar resolution during Wipe My Cal rescheduling > ><pre> >• Updates rescheduling cleanup to await the asynchronous calendar factory before deleting referenced events. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-e95d4be7604e04dd35b3f666cf4dcb03606fc55869bdcb01a0086f0800780900'>packages/app-store/wipemycalother/lib/reschedule.ts</a> </details> <details> <summary>CalendarManager.ts<code>Propagate asynchronous calendar creation through core operations</code> <code>+8/-7</code></summary> <br/> >Propagate asynchronous calendar creation through core operations > ><pre> >• Handles promised calendars when listing connected calendars and loading availability. Event creation, update, and deletion now await calendar resolution before invoking provider services. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-1edf77640cddbeb991fcd8211c16508c055ff086f3c04f58a4e951f1e6710b14'>packages/core/CalendarManager.ts</a> </details> <details> <summary>EventManager.ts<code>Await calendar loading before old-event cleanup</code> <code>+1/-2</code></summary> <br/> >Await calendar loading before old-event cleanup > ><pre> >• Resolves the calendar integration asynchronously before deleting an obsolete external calendar event. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-f028774ebd744c3141fb60f0fb171c59a2ae4773b285b70f834114e7a3d7afa2'>packages/core/EventManager.ts</a> </details> <details> <summary>videoClient.ts<code>Load video adapters from asynchronous app modules</code> <code>+20/-16</code></summary> <br/> >Load video adapters from asynchronous app modules > ><pre> >• Makes video adapter construction asynchronous and awaits app modules for availability, meeting lifecycle, fallback video, and recording operations. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-2a086d2662db706c13b517861f1969467f7db633b575af8e6cabfdc69d1081c0'>packages/core/videoClient.ts</a> </details> <details> <summary>handleCancelBooking.ts<code>Await integration modules throughout booking cancellation</code> <code>+12/-11</code></summary> <br/> >Await integration modules throughout booking cancellation > ><pre> >• Awaits calendar modules for event deletion, updates, recurring-booking cleanup, and legacy cancellation behavior. Payment service resolution is also updated for the asynchronous app registry. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-87a46901f0685bc1affbfaab91860fb47aaf0f689c17bd379a56d8a9aaa51716'>packages/features/bookings/lib/handleCancelBooking.ts</a> </details> <details> <summary>handleNewBooking.ts<code>Await calendar loading during booking rollback</code> <code>+1/-1</code></summary> <br/> >Await calendar loading during booking rollback > ><pre> >• Resolves calendar integrations asynchronously before deleting external events while cleaning up a failed or replaced booking. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-a7c21727d9a0d4d1aaff9d24fca9293bc28468861bc8022dfa03116908b6fae7'>packages/features/bookings/lib/handleNewBooking.ts</a> </details> <details> <summary>deletePayment.ts<code>Await payment module before deletion</code> <code>+1/-1</code></summary> <br/> >Await payment module before deletion > ><pre> >• Resolves the configured payment integration asynchronously before validating and invoking its PaymentService. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-9f2d52dabd251823f8feee613db71c5b26a6ccd30f104ac34dc5d5a9e9c6dbf1'>packages/lib/payment/deletePayment.ts</a> </details> <details> <summary>handlePayment.ts<code>Await payment module before processing</code> <code>+1/-1</code></summary> <br/> >Await payment module before processing > ><pre> >• Awaits the selected payment integration before validating and using its PaymentService implementation. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-c823c7dab045161c6f50c2a0edbeb07ae7f9efd67ce572fdf7d04f2ad4a3bf1a'>packages/lib/payment/handlePayment.ts</a> </details> <details> <summary>bookings.tsx<code>Resolve booking integrations asynchronously in the viewer router</code> <code>+3/-3</code></summary> <br/> >Resolve booking integrations asynchronously in the viewer router > ><pre> >• Awaits calendar modules during rescheduling cleanup and payment modules during booking payment handling. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-1f41e2e253ba5e8709f8acc2db09d5ed70727be132f7c63d5ad6af734013cac8'>packages/trpc/server/routers/viewer/bookings.tsx</a> </details> </dd> </dl> </details> </dd> </dl> </details>
PR-level
<h3>Code Review by Qodo</h3> <code>🐞 Bugs (3)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <br/> <img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> <details> <summary> 1. Two app reschedules outrun cleanup <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >The Vital and WipeMyCalOther <b><i>Reschedule</i></b> implementations pass an async callback to <b><i>forEach</i></b>, so >the newly awaited <b><i>getCalendar</i></b> lookup is detached from the surrounding <b><i>try</i></b> block. When a >rescheduled booking has a calendar reference, each function can send its email and return before ><b><i>deleteEvent</i></b> starts, while lookup failures bypass the intended catch handler. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/app-store/vital/lib/reschedule.ts[125]](https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-45807fe7862f3b75cfbc6a78ca64fcb9b369b41f0230b164d0e19c0ecb3c18c2R125-R125)</code> > >```diff >+ bookingRefsFiltered.forEach(async (bookingRef) => { >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Both implementations invoke <b><i>forEach</i></b> with an async callback that pauses at <b><i>getCalendar</i></b>, but >immediately continue to the email block and return. Since <b><i>getCalendar</i></b> now awaits the selected >dynamic import, calendar deletion is no longer initiated synchronously before control leaves the >loop. ></pre> > > <code>[packages/app-store/vital/lib/reschedule.ts[124-151]](https://github.com/drape-io/crbench-qodo-2026-09/blob/c09e523fa4128b265a3e6d9df4ec0df668b754f3/packages/app-store/vital/lib/reschedule.ts/#L124-L151)</code> > <code>[packages/app-store/wipemycalother/lib/reschedule.ts[124-151]](https://github.com/drape-io/crbench-qodo-2026-09/blob/c09e523fa4128b265a3e6d9df4ec0df668b754f3/packages/app-store/wipemycalother/lib/reschedule.ts/#L124-L151)</code> > <code>[packages/app-store/_utils/getCalendar.ts[9-18]](https://github.com/drape-io/crbench-qodo-2026-09/blob/c09e523fa4128b265a3e6d9df4ec0df668b754f3/packages/app-store/_utils/getCalendar.ts/#L9-L18)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Vital and WipeMyCalOther rescheduling launch asynchronous calendar cleanup through `forEach`, which does not await its callback. The enclosing functions can therefore finish before calendar deletion starts, and their `try/catch` blocks do not receive asynchronous failures. > >## Fix Focus Areas >- packages/app-store/vital/lib/reschedule.ts[124-139] >- packages/app-store/wipemycalother/lib/reschedule.ts[124-139] > >## Recommended Fix >Replace each async `forEach` with an awaited `Promise.all(bookingRefsFiltered.map(...))` or an awaited `for...of` loop. Keep both calendar and video deletion promises inside the awaited operation so the existing error handler covers lookup and cleanup failures. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 2. Viewer reschedules outrun cleanup <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >The viewer reschedule route passes an async callback to <b><i>bookingRefsFiltered.forEach</i></b>, leaving the >newly awaited calendar lookup outside the route&#x27;s awaited sequence. For calendar-backed bookings, >execution reaches <b><i>sendRequestRescheduleEmail</i></b> while the app module is still loading, and lookup or >deletion failures are not propagated through the route. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/bookings.tsx[553]](https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-1f41e2e253ba5e8709f8acc2db09d5ed70727be132f7c63d5ad6af734013cac8R553-R553)</code> > >```diff >+ bookingRefsFiltered.forEach(async (bookingRef) => { >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The async callback awaits <b><i>getCalendar</i></b> at line 556, but <b><i>forEach</i></b> discards its promise and the >route immediately sends the reschedule email at lines 569-572. The calendar factory now performs an >asynchronous module lookup, establishing a real yield before <b><i>deleteEvent</i></b> is invoked. ></pre> > > <code>[packages/trpc/server/routers/viewer/bookings.tsx[544-572]](https://github.com/drape-io/crbench-qodo-2026-09/blob/c09e523fa4128b265a3e6d9df4ec0df668b754f3/packages/trpc/server/routers/viewer/bookings.tsx/#L544-L572)</code> > <code>[packages/app-store/_utils/getCalendar.ts[9-18]](https://github.com/drape-io/crbench-qodo-2026-09/blob/c09e523fa4128b265a3e6d9df4ec0df668b754f3/packages/app-store/_utils/getCalendar.ts/#L9-L18)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The viewer reschedule path launches calendar and video cleanup through an async `forEach` callback. Calendar cleanup now yields while resolving the app module, allowing the route to send its email and continue without waiting for cleanup or receiving its failures. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/bookings.tsx[550-570] > >## Recommended Fix >Replace the async `forEach` with `await Promise.all(bookingRefsFiltered.map(...))` or an awaited `for...of` loop. Return or await both calendar and video deletion operations so cleanup completes, or fails the request, before the email is sent. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 3. Recurring cleanup starts too late <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >The recurring-cancellation branch adds <b><i>await getCalendar</i></b> inside an async <b><i>forEach</i></b> callback whose >promise is discarded. When remaining recurring bookings need calendar removal, the handler can reach >the final <b><i>Promise.all</i></b> before those lookups resolve, so deletions have not yet been initiated or >added to <b><i>apiDeletes</i></b>. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/features/bookings/lib/handleCancelBooking.ts[461]](https://github.com/drape-io/crbench-qodo-2026-09/pull/24/files#diff-87a46901f0685bc1affbfaab91860fb47aaf0f689c17bd379a56d8a9aaa51716R461-R461)</code> > >```diff >+ const calendar = await getCalendar(credential); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The callback yields at line 461 before entering the booking loop, while the enclosing handler >continues independently. The only aggregate wait occurs later using ><b><i>prismaPromises.concat(apiDeletes)</i></b>, which cannot include values pushed after that array is >evaluated. ></pre> > > <code>[packages/features/bookings/lib/handleCancelBooking.ts[437-470]](https://github.com/drape-io/crbench-qodo-2026-09/blob/c09e523fa4128b265a3e6d9df4ec0df668b754f3/packages/features/bookings/lib/handleCancelBooking.ts/#L437-L470)</code> > <code>[packages/features/bookings/lib/handleCancelBooking.ts[650-654]](https://github.com/drape-io/crbench-qodo-2026-09/blob/c09e523fa4128b265a3e6d9df4ec0df668b754f3/packages/features/bookings/lib/handleCancelBooking.ts/#L650-L654)</code> > <code>[packages/app-store/_utils/getCalendar.ts[9-18]](https://github.com/drape-io/crbench-qodo-2026-09/blob/c09e523fa4128b265a3e6d9df4ec0df668b754f3/packages/app-store/_utils/getCalendar.ts/#L9-L18)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Recurring calendar cleanup pauses at the asynchronous calendar factory inside an unawaited `forEach` callback. The cancellation handler can snapshot `apiDeletes` and finish before those callbacks initiate their deletions. > >## Fix Focus Areas >- packages/features/bookings/lib/handleCancelBooking.ts[458-470] >- packages/features/bookings/lib/handleCancelBooking.ts[650-654] > >## Recommended Fix >Replace the async `forEach` with an awaited loop or construct deletion promises with nested `flatMap`/`map` calls and await them directly. Do not asynchronously push resolved deletion results into `apiDeletes`; add actual promises before the final `Promise.all`, or complete the recurring cleanup before proceeding. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-context:start --> <details><summary><strong>Context sources</strong></summary> <div>Review mode: <code>⚖️ Balanced</code>: Downgraded extended -&gt; standard: change is below the extended eligibility bar (hunks 29/18, lines 189/200; both must reach the floor). Router rationale: This broad async lazy-loading refactor spans calendar, video, payment, booking, and core paths, with multiple independent call-site changes and several easy-to-miss async control-flow risks.</div> <!-- qodo-context:end --> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:start --> <details> <summary><strong>Tip of the day</strong></summary> <br/> <pre>💡 Did you know, you can reply &#x27;qodo&#x27; on any finding to push back, ask questions, or dig deeper</pre> <a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:end --> <!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/c09e523fa4128b265a3e6d9df4ec0df668b754f3 --> <a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>