fix: Show error log (#14960)

This commit is contained in:
Hariom Balhara
2024-05-10 08:47:57 +01:00
committed by GitHub
parent c65dca9486
commit a136511c8a
2 changed files with 5 additions and 1 deletions
@@ -1,6 +1,8 @@
import type { GetServerSidePropsContext } from "next";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { asStringOrThrow } from "@lib/asStringOrNull";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
@@ -40,6 +42,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const { eventType } = await ssr.viewer.eventTypes.get.fetch({ id: eventTypeId });
return eventType;
} catch (e: unknown) {
logger.error(safeStringify(e));
// reject, user has no access to this event type.
return null;
}
+2 -1
View File
@@ -5,7 +5,8 @@ export function safeStringify(obj: unknown) {
try {
if (obj instanceof Error) {
// Errors don't serialize well, so we extract what we want
return obj.stack ?? obj.message;
// We stringify so that we can log the error message and stack trace in a single log event
return JSON.stringify(obj.stack ?? obj.message);
}
// Avoid crashing on circular references
return JSON.stringify(obj);