File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
packages/nextjs/src/common/pages-router-instrumentation Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,16 @@ export function wrapErrorGetInitialPropsWithSentry(
4848 sentryTrace ?: string ;
4949 } = await tracedGetInitialProps . apply ( thisArg , args ) ;
5050
51- // The Next.js serializer throws on undefined values so we need to guard for it (#12102)
52- if ( sentryTrace ) {
53- ( errorGetInitialProps as Record < string , unknown > ) . _sentryTraceData = sentryTrace ;
54- }
51+ if ( typeof errorGetInitialProps === 'object' && errorGetInitialProps !== null ) {
52+ if ( sentryTrace ) {
53+ // The Next.js serializer throws on undefined values so we need to guard for it (#12102)
54+ ( errorGetInitialProps as Record < string , unknown > ) . _sentryTraceData = sentryTrace ;
55+ }
5556
56- // The Next.js serializer throws on undefined values so we need to guard for it (#12102)
57- if ( baggage ) {
58- ( errorGetInitialProps as Record < string , unknown > ) . _sentryBaggage = baggage ;
57+ // The Next.js serializer throws on undefined values so we need to guard for it (#12102)
58+ if ( baggage ) {
59+ ( errorGetInitialProps as Record < string , unknown > ) . _sentryBaggage = baggage ;
60+ }
5961 }
6062
6163 return errorGetInitialProps ;
Original file line number Diff line number Diff line change @@ -34,9 +34,13 @@ export function wrapGetServerSidePropsWithSentry(
3434 data : serverSideProps ,
3535 baggage,
3636 sentryTrace,
37+ } : {
38+ data ?: unknown ;
39+ baggage ?: string ;
40+ sentryTrace ?: string ;
3741 } = await ( tracedGetServerSideProps . apply ( thisArg , args ) as ReturnType < typeof tracedGetServerSideProps > ) ;
3842
39- if ( typeof serverSideProps === 'object' && 'props' in serverSideProps ) {
43+ if ( typeof serverSideProps === 'object' && serverSideProps !== null && 'props' in serverSideProps ) {
4044 // The Next.js serializer throws on undefined values so we need to guard for it (#12102)
4145 if ( sentryTrace ) {
4246 ( serverSideProps . props as Record < string , unknown > ) . _sentryTraceData = sentryTrace ;
You can’t perform that action at this time.
0 commit comments