Prevent timeouts when cache fails (#7095)
Return empty cache instead of failing Keeping console errors
This commit is contained in:
1 parent
b6eca6e083
commit
8e2ece7526
2 files changed
+23
-8
No files matched your search
@@ -33,13 +33,28 @@ export const getStaticProps: GetStaticProps<
|
|||||||
dayjs(month, "YYYY-MM").isSame(dayjs(), "month") ? dayjs() : dayjs(month, "YYYY-MM")
|
dayjs(month, "YYYY-MM").isSame(dayjs(), "month") ? dayjs() : dayjs(month, "YYYY-MM")
|
||||||
).startOf("day");
|
).startOf("day");
|
||||||
const endDate = startDate.endOf("month");
|
const endDate = startDate.endOf("month");
|
||||||
const results = user?.credentials
|
try {
|
||||||
? await getCachedResults(user?.credentials, startDate.format(), endDate.format(), user?.selectedCalendars)
|
const results = user?.credentials
|
||||||
: [];
|
? await getCachedResults(
|
||||||
return {
|
user?.credentials,
|
||||||
props: { results, date: new Date().toISOString() },
|
startDate.format(),
|
||||||
revalidate: 1,
|
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 = () => {
|
export const getStaticPaths: GetStaticPaths = () => {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ export default trpcNext.createNextApiHandler({
|
|||||||
"viewer.public.session": `no-cache`,
|
"viewer.public.session": `no-cache`,
|
||||||
"viewer.public.i18n": `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
|
// 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;
|
} as const;
|
||||||
|
|
||||||
// Find which element above is an exact match for this group of paths
|
// Find which element above is an exact match for this group of paths
|
||||||
|
|||||||
Reference in new issue
Block a user