cal.com · pull request 8087
CriticalFound in 4 of 4 passes
Known bug, in the answer key's words
The code uses forEach with async callbacks, which causes asynchronous operations (e.g., calendar/video event deletions, payment refunds) to run concurrently without being awaited. This 'fire-and-forget' behavior leads to unhandled promise rejections, race conditions, and incomplete cleanup…
Our comment packages/trpc/server/routers/viewer/bookings.tsx:553
forEach(async) is used for the calendar deletions on reschedule. The deletions are not awaited, and the surrounding try/catch cannot catch errors from the async callback. … A failure in getCalendar or deleteEvent becomes an unhandled promise rejection, which can crash a Node process … Use Promise.all(refs.map(async ...)) with an await.
Show the code
bookingRefsFiltered.forEach(async (bookingRef) => {
const calendar = await getCalendar(credentialsMap.get(bookingRef.type));