Skip to content

Sentry (@sentry/nextjs v10) integration is disabled — legacy config pattern crashes the build, zero error monitoring ships #1301

Description

@milah-247

Summary

novaRewards/frontend's Sentry integration (@sentry/nextjs@^10.50.0) is currently completely disabled and, before that, was actively crashing the production build. Error monitoring does not exist in this application right now, and re-enabling it naively (by just re-adding withSentryConfig) will reproduce the crash.

What's currently wired vs. what v10 needs

The repo has three legacy auto-loaded config files: sentry.client.config.js, sentry.server.config.js, sentry.edge.config.js, each calling Sentry.init(...) directly at module scope. This was the pattern for Sentry SDK v7/v8. Sentry SDK v10 requires the instrumentation.ts (server/edge) + instrumentation-client.ts (client) registration pattern instead — the build itself says so:

[@sentry/nextjs] It appears you've configured a `sentry.server.config.js` file. Please ensure to put
this file's content into the `register()` function of a Next.js instrumentation file instead...
[@sentry/nextjs] Could not find a Next.js instrumentation file. This indicates an incomplete
configuration of the Sentry SDK...
[@sentry/nextjs] It seems like you don't have a global error handler set up...
[@sentry/nextjs] DEPRECATION WARNING: It is recommended renaming your `sentry.client.config.js` file...

With withSentryConfig(...) still wrapping next.config.js (as it was originally), next build's static-generation step crashed on every page:

TypeError: Cannot read properties of null (reading 'useContext')
    at o (.next/server/chunks/708.js:1:2709)
    at w (.next/server/chunks/939.js:1:23951)
Error occurred prerendering page "/"

i.e. Sentry's webpack instrumentation, wrapping page components under the old/incompatible config pattern, was producing broken output that crashed React during prerendering — not a flake, reproduced consistently across multiple builds.

Current state (workaround, not a fix)

To unblock the production build, withSentryConfig has been removed from next.config.js entirely (it now just exports withBundleAnalyzer(nextConfig)), and a comment was left explaining why. This means:

  • No error monitoring, performance tracing, session replay, or release tracking ships to production at all.
  • The sentry.*.config.js files, NEXT_PUBLIC_SENTRY_DSN/SENTRY_ORG/SENTRY_PROJECT/SENTRY_AUTH_TOKEN env vars, and the source-map upload plugin options in next.config.js's (now-removed) sentryWebpackPluginOptions are all dead configuration.

Suggested approach

  1. Follow the Sentry Next.js v10 migration guide: create instrumentation.ts at the project root with a register() function that calls Sentry.init(...) for the server/edge runtimes (port the content of sentry.server.config.js/sentry.edge.config.js in, branching on NEXT_RUNTIME), and instrumentation-client.ts for the client-side init (port sentry.client.config.js).
  2. Add a global-error.tsx at the app root wired to Sentry.captureException (the build warning explicitly flags this as missing) so React rendering errors are actually reported.
  3. Delete the now-obsolete sentry.server.config.js / sentry.edge.config.js / sentry.client.config.js.
  4. Re-add withSentryConfig(withBundleAnalyzer(nextConfig), sentryWebpackPluginOptions) in next.config.js and confirm next build completes cleanly with it in place — this needs to be verified against a real (or dummy) NEXT_PUBLIC_SENTRY_DSN, since the crash may only have reproduced under specific env conditions (this environment had no DSN configured, which didn't prevent the crash — worth confirming whether a real DSN changes anything).
  5. Once building cleanly, verify an actual test event reaches Sentry (throw a test error behind a debug route) before considering this closed — a build that merely compiles with Sentry re-enabled isn't proof monitoring actually works.

Priority

High — this is a production observability gap (zero error visibility) sitting behind what currently looks, from the outside, like intentional/working Sentry configuration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdevopsDevOps and infrastructure workfrontendFrontend Next.js workpriority: highHigh priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions