Skip to content
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

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

Closed
3 tasks done
Leo1212 opened this issue Dec 9, 2022 · 1 comment · Fixed by #6572
Closed
3 tasks done

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

Leo1212 opened this issue Dec 9, 2022 · 1 comment · Fixed by #6572
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug

Comments

@Leo1212
Copy link

Leo1212 commented Dec 9, 2022

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)
@Leo1212 Leo1212 changed the title NextJs _document.tsx implmentation broken since version 7.17.0 Next.js _document.tsx implmentation broken since version 7.17.0 Dec 9, 2022
@lforst
Copy link
Member

lforst commented Dec 9, 2022

Hi, thanks for reporting this. I can see what is going wrong here. I believe we're not properly passing this context to the wrapped getInitialProps function of the _document component that @rest-hooks exports.

We'll take care of fixing this. In the meanwhile, you can set the instrumentServerFunctions option to false: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#disable-api-route-and-data-fetching-auto-instrumentation-entirely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants