Skip to content

Next.js _document.tsx implmentation broken since version 7.17.0 #6479

@Leo1212

Description

@Leo1212

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.24.2

Framework Version

React 18.2.0

Link to Sentry event

No response

Steps to Reproduce

  1. run git clone https://github.com/Leo1212/sentry-nextjs-issue.git
  2. run cd sentry-nextjs-issue
  3. run yarn
  4. run yarn run next build
  5. See the result --> error building
  6. Change in the package.json the version of @sentry/nextjs to 7.16.0
  7. run yarn
  8. run yarn run next build
  9. build --> success

Expected Result

A successful NextJS build.

Route (pages)                              Size     First Load JS
┌ ○ / (394 ms)                             4.33 kB         116 kB
├   └ css/ae0e3e027412e072.css             707 B
├   /_app                                  0 B             112 kB
├ ○ /404                                   181 B           112 kB
└ λ /api/hello                             0 B             112 kB
+ First Load JS shared by all              112 kB
  ├ chunks/framework-8c5acb0054140387.js   45.4 kB
  ├ chunks/main-f2e125da23ccdc4a.js        26.7 kB
  ├ chunks/pages/_app-dfb8b8961ce26b8d.js  38.6 kB
  ├ chunks/webpack-94547de1949c56d7.js     950 B
  └ css/ab44ce7add5c3d11.css               247 B

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)

Done in 14.59s.

Actual Result

The build fails do to the sentry implementation of the _document.tsx file. If you delete ist, it works. But I need this file.
Funny thing is, it worked on the older versions of @sentry/nextjs (7.16.0 and below).

The same issue is also mentioned here: vercel/next.js#36221 (comment)

[=   ] info  - Generating static pages (0/3)
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of undefined (reading 'getNonce')
    at getInitialProps (file:///pathToRepo/sentry-demo/node_modules/@rest-hooks/ssr/lib/nextjs/RestHooksDocument.js:28:19)

Metadata

Metadata

Assignees

Labels

Package: nextjsIssues related to the Sentry Nextjs SDK

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions