Repository navigation
Description
Problem Statement
On Next.js 16.4 with Turbopack, the browser SDK can be removed from the build without any warning. Our production app ran for four weeks with no browser errors, traces or replays before we noticed.
The trigger is a sideEffects field in the app's package.json. Ours was ["**/*.css"], added to enable tree-shaking. instrumentation-client.ts follows the documented setup: it calls Sentry.init({...}) and re-exports captureRouterTransitionStart as onRouterTransitionStart. Since Next.js 16.4 (vercel/next.js#97770), Turbopack drops the module's body, init() included, whenever the package declares the file side-effect free; in our bundle only the re-export was left. In the browser @sentry/nextjs still loads, but no client is ever created.
Nothing reports it:
- The build succeeds and the Sentry release is still created.
- The 11.10 build-time warning (feat(nextjs): Warn when Next.js production builds miss the instrumentation file #25603) checks only that
instrumentation.tsexists. - The troubleshooting page mentions
sideEffects: false, but not an allow-list such as["**/*.css"], which has the same effect oninstrumentation-client.ts. Document how to handlesideEffects#9787 hit the same failure under webpack in 2024 and was closed with that docs note.
Next.js issue with a minimal reproduction (no Sentry code): vercel/next.js#102502
Reproduction repo: https://github.com/itsUndefined/next-instrumentation-client-sideeffects-repro
Solution Brainstorm
- Build-time check (main proposal). Under Turbopack,
withSentryConfig's value-injection loader already writes values such as_sentryNextJsVersionand_sentryRouteManifestintoinstrumentation-client. They sit in the same module body asinit(), so they disappear with it: the client chunks of our broken production build contained none of them, while in the fixed build they appear in the chunks that containinit. After the production compile, the plugin could check that at least one client chunk still contains an injected marker, and warn (or fail) if none does. That catches any cause of the body being dropped, not onlysideEffects, and needs no knowledge of which chunk is the entry. - Runtime: in debug builds, log a warning the first time
captureRouterTransitionStartruns while no client exists. - Docs: extend the troubleshooting entry to cover
sideEffectsarrays and Next.js 16.4+ Turbopack, with the fix (add./instrumentation-client.tstosideEffects, or remove the field).
Happy to send a PR for the build-time check if this direction works for you.
Additional Context
Seen with @sentry/nextjs 10.78 on Next.js 16.4.3 to 16.4.6 (Pages Router, Turbopack, deployed on Vercel). Next.js 16.3.5 and webpack builds keep the init. As far as we can tell from the 11.x changelog and migration guide, v11 doesn't detect this either.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Nov 27, 2026
JS-4176
logaretm commentedon Nov 27, 2026
Thanks for the detailed report, this seems like a turbopack regression. At first glance it doesn't seem like we should add a warning to the SDK because this is not an expected outcome from a bundler IMO.
Since there is a workaround then I would recommend using it in the meanwhile.