-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
wrapGetInitialPropsWithSentry throws an exception if getInitialProps returns undefined #9066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is what the TypeScript type being emitted say: https://github.com/vercel/next.js/blob/628a19393bea4e40af3ef73b101669e1c2fdd672/packages/next/src/shared/lib/utils.ts#L21C62-L21C74 We can try and guard around this, but we generally expect the TS types from Next.js to be respected and it can be resolved by easily adjusting your app's I'll defer to @lforst to make the call though. |
Thanks for raising this. I'd say if Next.js itself doesn't throw, the SDK shouldn't either. We'll guard for this. |
Thanks for the quick response! I'll add that the typing from nextjs is very weak, as |
Fix released with https://github.com/getsentry/sentry-javascript/releases/tag/7.75.0 |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
7.69.0
Framework Version
React 17.0, NextJS 12.1.0
Link to Sentry event
https://ardian.sentry.io/issues/4480381245/
SDK Setup
No response
Steps to Reproduce
If a page's
getInitialProps
function does not return an object, but rather undefined or null, Sentry will throw an exception on that page. This is because of this piece of code inwrapGetInitialPropsWithSentry.ts
:The specific error is
TypeError: Cannot set properties of undefined (setting '_sentryTraceData')
For context, I had a page's
getInitialProps
returning undefined because I only usedgetInitialProps
to handle server-side redirections.I don't know if this can easliy modified whilde still keeping the instrumentation, but the exception could at least be caught to not bubble up and crash the whole page.
Expected Result
Sentry doesn't throw an exception if
getInitialProps
returns undefinedActual Result
Sentry throws an exception if
getInitialProps
returns undefined, crashing the whole page.The text was updated successfully, but these errors were encountered: