Skip to content

fix(nextjs): Use passthrough createReduxEnhancer on server #11005

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

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

lforst
Copy link
Contributor

@lforst lforst commented Mar 11, 2024

Ref #10366

In #9854 we added createReduxEnhancer to the serverside Next.js SDK. This import pulls in all side-effects of the @sentry/react SDK. One side-effect is that the Profiler class has a static initializer, meaning it ends up in the server bundle- This now turns out to be a problem because Next.js does not seem to strip the Profiler class away (even if it is unused), and it crashes because it extends React.Component which is not available in the Next.js App Router server context.

We solve this by "vendoring" a noop redux enhancer instead of exporting the one from @sentry/react.

@lforst lforst marked this pull request as ready for review March 11, 2024 11:39
@lforst lforst requested review from mydea, Lms24 and s1gr1d March 11, 2024 11:39
"ts-node": "10.9.1",
"@playwright/test": "^1.27.1"
"typescript": "4.9.5",
"wait-port": "1.0.4"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to clarify, are these new deps important/needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not new. Yarn just auto sorted them. The only thing I did was bump the version the default e2e tests run with to the latest version. I think that is needed. At least it was to verify this bug.

@lforst lforst merged commit 6d4af1c into develop Mar 11, 2024
@lforst lforst deleted the lforst-fix-react-side-effect-next-js-sadness branch March 11, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants