Skip to content

docs: Clarify Node.js specific imports in Next.js register hook migration guide #11878

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

Conversation

lforst
Copy link
Contributor

@lforst lforst commented May 3, 2024

#11823 rightfully mentioned that the way we recommend people to init the SDK may crash if there are nodejs specific packages being imported in instrumentation.ts.

We could solve this by either changing the way we recommend users to add configuration like so:

import * as Sentry from '@sentry/nextjs';

export async function register() {
  if (process.env.NEXT_RUNTIME === 'nodejs') {
    await import('./sentry.server.config.ts');
  }

  if (process.env.NEXT_RUNTIME === 'edge') {
    await import('./sentry.edge.config.ts');
  }
}

But for now I'd rather keep the base-case simple and add additional explanation for the more complicated case. Maybe we need to switch this up in the future.

@lforst lforst merged commit 85c754a into develop May 3, 2024
28 checks passed
@lforst lforst deleted the lforst-clarify-node-specific-imports-in-nextjs-register branch May 3, 2024 07:52
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