question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot set properties of undefined (setting '_sentryTraceData')

See original GitHub issue

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.14.2

Framework Version

React 18.1.0

Link to Sentry event

No response

Steps to Reproduce

Hello, Thank you for quickly addressing issue #5877 . I saw that issue was fixed in 7.14.2 and tried it today.

Build was successful, but a runtime error occurred.

TypeError: Cannot set properties of undefined (setting '_sentryTraceData')
    at Function.getInitialProps (/app/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryServerSideAppGetInitialProps.js:44:55)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.loadGetInitialProps (/app/node_modules/next/dist/shared/lib/utils.js:70:19)
    at async Object.renderToHTML (/app/node_modules/next/dist/server/render.js:436:14)
    at async doRender (/app/node_modules/next/dist/server/base-server.js:917:38)
    at async cacheEntry.responseCache.get.isManualRevalidate.isManualRevalidate (/app/node_modules/next/dist/server/base-server.js:1022:28)
    at async /app/node_modules/next/dist/server/response-cache.js:69:36

TypeError: Cannot set properties of undefined (setting '_sentryTraceData')

I am using next.js v12.2 - using SSR(ISR)

next.config.js

  sentry: {
    hideSourceMaps: true,
    autoInstrumentServerFunctions: true,
  },

Expected Result

The application builds normally.

Actual Result

Internal Server Error

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
lforstcommented, Oct 7, 2022

@ccj9707

I feel like this one (for a change 😄) isn’t on us.

The Next.js docs on custom apps state that if you have a getInitialProps in your _app.js, you must call App.getInitialProps(appContext) and merge its return values with your initial props.

Here’s the code example from the docs:

import App from 'next/app'

function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />
}

MyApp.getInitialProps = async (appContext) => {
  // calls page's `getInitialProps` and fills `appProps.pageProps`
  const appProps = await App.getInitialProps(appContext);

  return { ...appProps }
}

export default MyApp
3reactions
ccj9707commented, Oct 7, 2022

@lforst Problem solved! Thanks, I’ve corrected the weird stuff.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot set properties of undefined (setting 'duration')
What is happening is that you are trying to access an item in the list using the index listOfSelectedQuestions[index] but the item doesn't ......
Read more >
Cannot set properties of undefined (setting '_sentryTraceData')
Build was successful, but a runtime error occurred. TypeError: Cannot set properties of undefined (setting '_sentryTraceData') at Function.
Read more >
vite: TypeError: Cannot set properties of undefined (setting 'j ...
... project template? when i run the example json_schema_validation.svelte, i get the error. Uncaught SyntaxError: The requested module '/node_modules/.pnpm/ ...
Read more >
Cannot set properties of undefined Ammo - Bugs - Babylon.js
Hello everyone! So im having a bug where i installed the AmmoJS but when i use it its not working i dont really...
Read more >
TypeError: Cannot set properties of Undefined in JavaScript
The "Cannot set properties of undefined" error occurs when setting a property on an `undefined` value. To solve the error conditionally check if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found