-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(nextjs): Skip re instrumentating on generate phase of experimental build mode #16410
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
Conversation
showedExperimentalBuildModeWarning = true; | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
'[@sentry/nextjs] The Sentry Next.js SDK does not currently fully support next build --experimental-build-mode', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like us to expand this comment to be more specific to what we don't support, or link to a docs page that explains this in more detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can write something up in the docs and link it here when it's ready; yet i'm not sure how useful it'll be for users. Source maps, tracing, and error handling work as expected for now, but since we inline things differently at compile time than what Next.js does, some issues might still come up and it's just good to flag -if something breaks- that this isn't a fully robust solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having something there is useful because we can add items to it as it comes up, even if nothing is too important atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, will add it to the docs! Is this a blocker for this PR though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a PR blocker, we can do it as a follow up
Co-authored-by: Charly Gomez <[email protected]>
showedExperimentalBuildModeWarning = true; | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
'[@sentry/nextjs] The Sentry Next.js SDK does not currently fully support next build --experimental-build-mode', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a PR blocker, we can do it as a follow up
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:
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.