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

feat(nextjs): Add experimental_captureRequestError for onRequestError hook #12885

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

lforst
Copy link
Member

@lforst lforst commented Jul 11, 2024

This PR adds an experimental implementation of an error handler that can be used to capture errors for the onRequestError hook recently added to Next.js canary: vercel/next.js#67539

The handler can be added to the instrumentation.ts file as follows:

// instrumentation.ts
import * as Sentry from '@sentry/nextjs';

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

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

export const onRequestError = Sentry.experimental_captureRequestError;

Currently, Next.js requires a __NEXT_EXPERIMENTAL_INSTRUMENTATION=1 environment variable for this feature to work.

@lforst lforst changed the title feat(nextjs): Add experimental_captureRequestError feat(nextjs): Add experimental_captureRequestError for onRequestError hook Jul 12, 2024
@lforst lforst requested review from chargome and andreiborza July 12, 2024 08:33
Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

Nice!

@lforst lforst merged commit d67df35 into develop Jul 12, 2024
94 checks passed
@lforst lforst deleted the lforst-nextjs-onrequesterrorwrapper branch July 12, 2024 09:29
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