You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(nextjs): Skip re instrumentating on generate phase of experimental build mode (#16410)
Next.js v15.3.0-canary.1 introduced a new approach to the two-phase
experimental build (--experimental-build-mode=compile then =generate)
that applies env inlining during generate build mode.
Why it breaks?
Our `withSentryConfig` still assumes a single “full” build and reruns
its Webpack instrumentation in both phases. During the generate step it
collides with Next.js’s new inliner (e.g. for assetPrefix), producing
malformed JS and build failures.
Root cause: Double application of build-time transforms—Sentry
inlines/reprocesses a bundle that Next.js’s generate mode is
simultaneously trying to finalize—leads to conflicting replacements and
syntax errors.
This PR is a quick workaround that patches our build script so that:
1. Compile phase (--experimental-build-mode=compile): Sentry’s
instrumentation runs as usual.
2. Generate phase (--experimental-build-mode=generate): We skip Sentry’s
build-time hooks entirely, letting Next.js handle inlining and
prerendering without collision.
This immediately prevents the build failures and defers full “generate”
work to Next.js’s own pipeline. I confirmed that source maps and error /
tracing still function as expected, BUT things might still occur as it's
still an experimental undocumented feature.
---------
Co-authored-by: Charly Gomez <[email protected]>
0 commit comments