Skip to content

Commit 7c84181

Browse files
author
Luca Forstner
authored
fix(nextjs): Guard for case where getInitialProps may return undefined (#9342)
1 parent a0ff516 commit 7c84181

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/nextjs/src/common/wrapGetInitialPropsWithSentry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function wrapGetInitialPropsWithSentry(origGetInitialProps: GetInitialPro
4646
const initialProps: {
4747
_sentryTraceData?: string;
4848
_sentryBaggage?: string;
49-
} = await tracedGetInitialProps.apply(thisArg, args);
49+
} = (await tracedGetInitialProps.apply(thisArg, args)) ?? {}; // Next.js allows undefined to be returned from a getInitialPropsFunction.
5050

5151
const requestTransaction = getTransactionFromRequest(req) ?? hub.getScope().getTransaction();
5252
if (requestTransaction) {

0 commit comments

Comments
 (0)