From 7c84181398dbf6ef5060cebac2f7b90ea0589617 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 24 Oct 2023 11:44:57 +0200 Subject: [PATCH] fix(nextjs): Guard for case where `getInitialProps` may return undefined (#9342) --- 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) {