From fffdbb03b4b2d76b3cef5776ece51aa5e5f2084d Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 24 Oct 2023 09:19:38 +0000 Subject: [PATCH] fix(nextjs): Guard for case where `getInitialProps` may return undefined --- packages/nextjs/src/common/wrapGetInitialPropsWithSentry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/src/common/wrapGetInitialPropsWithSentry.ts b/packages/nextjs/src/common/wrapGetInitialPropsWithSentry.ts index 601105bab7be..0ebe0ba79d13 100644 --- a/packages/nextjs/src/common/wrapGetInitialPropsWithSentry.ts +++ b/packages/nextjs/src/common/wrapGetInitialPropsWithSentry.ts @@ -46,7 +46,7 @@ export function wrapGetInitialPropsWithSentry(origGetInitialProps: GetInitialPro const initialProps: { _sentryTraceData?: string; _sentryBaggage?: string; - } = await tracedGetInitialProps.apply(thisArg, args); + } = (await tracedGetInitialProps.apply(thisArg, args)) ?? {}; // Next.js allows undefined to be returned from a getInitialPropsFunction. const requestTransaction = getTransactionFromRequest(req) ?? hub.getScope().getTransaction(); if (requestTransaction) {