Skip to content

Commit 9b0700f

Browse files
authored
fix(nextjs): Prevent infinite recompilation in dev (#4123)
#4017 introduced a bug wherein running the dev server would lead to an infinite recompilation loop. (Something about the implementation tricks the file watcher into thinking there's been a change when there hasn't.) Fortunately, since we don't upload sourcemaps in dev, the change made by that PR (accounting for the nextjs distDir option in our server-side RewriteFrames integration, which in turn enables sourcemaps to work) is actually a moot point there. This PR solves the issue by simply not applying that change to the dev server.
1 parent 60426d1 commit 9b0700f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ async function addSentryToEntryProperty(
138138
const filesToInject = [`./${userConfigFile}`];
139139

140140
// Support non-default output directories by making the output path (easy to get here at build-time) available to the
141-
// server SDK's default `RewriteFrames` instance (which needs it at runtime).
142-
if (buildContext.isServer) {
141+
// server SDK's default `RewriteFrames` instance (which needs it at runtime). Doesn't work when using the dev server
142+
// because it somehow tricks the file watcher into thinking that compilation itself is a file change, triggering an
143+
// infinite recompiling loop. (This should be fine because we don't upload sourcemaps in dev in any case.)
144+
if (buildContext.isServer && !buildContext.dev) {
143145
const rewriteFramesHelper = path.resolve(
144146
fs.mkdtempSync(path.resolve(os.tmpdir(), 'sentry-')),
145147
'rewriteFramesHelper.js',

0 commit comments

Comments
 (0)