Scheduling infrastructure for absolutely everyone.
Prevent timeouts when cache fails (#7095)
Omar López8e2ece75261e
diff --git a/apps/web/pages/[user]/calendar-cache/[month].tsx b/apps/web/pages/[user]/calendar-cache/[month].tsxindex 40badfe3638..423eedc0545 100644--- a/apps/web/pages/[user]/calendar-cache/[month].tsx+++ b/apps/web/pages/[user]/calendar-cache/[month].tsx@@ -33,13 +33,28 @@ export const getStaticProps: GetStaticProps<dayjs(month, "YYYY-MM").isSame(dayjs(), "month") ? dayjs() : dayjs(month, "YYYY-MM")).startOf("day");const endDate = startDate.endOf("month");- const results = user?.credentials- ? await getCachedResults(user?.credentials, startDate.format(), endDate.format(), user?.selectedCalendars)- : [];- return {- props: { results, date: new Date().toISOString() },- revalidate: 1,- };+ try {+ const results = user?.credentials+ ? await getCachedResults(+ user?.credentials,+ startDate.format(),+ endDate.format(),+ user?.selectedCalendars+ )+ : [];+ return {+ props: { results, date: new Date().toISOString() },+ revalidate: 1,+ };+ } catch (error) {+ let message = "Unknown error while fetching calendarƒ";+ if (error instanceof Error) message = error.message;+ console.error(error, message);+ return {+ props: { results: [], date: new Date().toISOString(), message },+ revalidate: 1,+ };+ }};export const getStaticPaths: GetStaticPaths = () => {diff --git a/apps/web/pages/api/trpc/[trpc].ts b/apps/web/pages/api/trpc/[trpc].tsindex af7802e3dcb..81a1e4598d0 100644--- a/apps/web/pages/api/trpc/[trpc].ts+++ b/apps/web/pages/api/trpc/[trpc].ts@@ -64,7 +64,7 @@ export default trpcNext.createNextApiHandler({"viewer.public.session": `no-cache`,"viewer.public.i18n": `no-cache`,// Revalidation time here should be 1 second, per https://github.com/calcom/cal.com/pull/6823#issuecomment-1423215321- "viewer.public.slots.getSchedule": `max-age=0, s-maxage=1`,+ "viewer.public.slots.getSchedule": `no-cache`, // FIXME} as const;// Find which element above is an exact match for this group of paths