Title: Next.js Class extends value undefined is not a constructor or null on v7.89.0 · Issue #10366 · getsentry/sentry-javascript · GitHub
Open Graph Title: Next.js Class extends value undefined is not a constructor or null on v7.89.0 · Issue #10366 · getsentry/sentry-javascript
X Title: Next.js Class extends value undefined is not a constructor or null on v7.89.0 · Issue #10366 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/10366
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Next.js Class extends value undefined is not a constructor or null on v7.89.0","articleBody":"### Is there an existing issue for this?\r\n\r\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\r\n- [X] I have reviewed the documentation https://docs.sentry.io/\r\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\r\n\r\n### How do you use Sentry?\r\n\r\nSentry Saas (sentry.io)\r\n\r\n### Which SDK are you using?\r\n\r\n@sentry/nextjs\r\n\r\n### SDK Version\r\n\r\n7.89.0\r\n\r\n### Framework Version\r\n\r\n7.89.0\r\n\r\n### Link to Sentry event\r\n\r\nhttps://the-key.sentry.io/issues/4917806857/?project=4506501905252352&query=is%3Aunresolved&referrer=issue-stream&statsPeriod=14d&stream_index=0\r\n\r\n### SDK Setup\r\n\r\n```\r\nif (process.env.NODE_ENV === 'production') {\r\n nextConfig = withSentryConfig(\r\n nextConfig,\r\n {\r\n // For all available options, see:\r\n // https://github.com/getsentry/sentry-webpack-plugin#options\r\n\r\n // Suppresses source map uploading logs during build\r\n silent: true,\r\n org: 'my-org',\r\n project: 'my-app-nextjs',\r\n },\r\n {\r\n // For all available options, see:\r\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\r\n\r\n // Upload a larger set of source maps for prettier stack traces (increases build time)\r\n widenClientFileUpload: true,\r\n\r\n // Transpiles SDK to be compatible with IE11 (increases bundle size)\r\n transpileClientSDK: false,\r\n\r\n // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)\r\n tunnelRoute: '/monitoring',\r\n\r\n // Hides source maps from generated client bundles\r\n hideSourceMaps: true,\r\n\r\n // Automatically tree-shake Sentry logger statements to reduce bundle size\r\n disableLogger: true,\r\n\r\n // Enables automatic instrumentation of Vercel Cron Monitors.\r\n // See the following for more information:\r\n // https://docs.sentry.io/product/crons/\r\n // https://vercel.com/docs/cron-jobs\r\n automaticVercelMonitors: false,\r\n }\r\n );\r\n}\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\nIn my Next v14.1.0 app, I loaded a page, when a component seems to change inside the page, it caused an error from Sentry:\r\n\r\n```\r\nClass extends value undefined is not a constructor or null\r\nThis might be caused by a React Class Component being rendered in a Server Component, React Class Components only works in Client Components. Read more: https://nextjs.org/docs/messages/class-component-in-server-component\r\n```\r\n\r\nI have worked out the code that is the problem is within a server-only function which is loaded on every page to fetch user data from my API, this function is also where I am setting the user for Sentry. \r\n\r\n```\r\nimport 'server-only';\r\n\r\nimport { cache } from 'react';\r\nimport { cookies } from 'next/headers';\r\nimport * as Sentry from '@sentry/nextjs';\r\n\r\n/**\r\n * Fetch user's data\r\n * @returns {User | null}\r\n */\r\nexport const fetchUser = cache(async (): Promise\u003cUser | null> => {\r\n const res = await fetch(`${API_ENDPOINT}/keyusers/?current=True`, {\r\n headers: {\r\n Cookie: `sessionid=${cookies().get('sessionid')?.value}`,\r\n 'Content-Type': 'application/json',\r\n },\r\n });\r\n \r\n if (!res.ok) {\r\n return null;\r\n }\r\n \r\n const data = await res.json();\r\n Sentry.setUser({ id: data.results[0].id });\r\n\r\n return data.results[0];\r\n});\r\n```\r\n\r\n\r\nIf I comment the Sentry parts out, everything works as expected.\r\n\r\nThis error doesn't occur on `v7.88.0` of `@sentry/nextjs`, so am stuck on this version for now. I use this function in several places within my monorepo, so am unable to upgrade Sentry until I can find a solution here.\r\n\r\n### Expected Result\r\n\r\nNo errors in the console to occur\r\n\r\n### Actual Result\r\n\r\n\r\n\r\n","author":{"url":"https://github.com/cpotey","@type":"Person","name":"cpotey"},"datePublished":"2024-01-26T12:34:12Z","url":"https://github.com/getsentry/sentry-javascript/issues/10366"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f23bed3f-e279-2c77-b388-d56b1894a2fa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C208:CFE11:91B37:CF81F:6B03FF7E |
| html-safe-nonce | 23d39fe537ddb9d0210833b40156525f30395b1facb74ecf8682fd9062e8f49b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjA4OkNGRTExOjkxQjM3OkNGODFGOjZCMDNGRjdFIiwidmlzaXRvcl9pZCI6Ijg5Njc1NzgzMzM1NTQ2NzE0ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9a5a7dbb19ca23109c2061308474e86461bf06c6a8a5d57b613a1ab4ee4f7ccc |
| hovercard-subject-tag | issue:2102146204 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/10366/issue_layout |
| twitter:image | https://opengraph.githubassets.com/950cc41ee499137a48761428836f0821b67584785f90a6a67e7442a201504b0c/getsentry/sentry-javascript/issues/10366 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/950cc41ee499137a48761428836f0821b67584785f90a6a67e7442a201504b0c/getsentry/sentry-javascript/issues/10366 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cpotey |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width