fix: Show error log (#14960)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user