Skip to content

Commit

Permalink
fix(nextjs): Prevent infinite recompilation in dev (#4123)
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
lobsterkatie committed Nov 5, 2021
1 parent 60426d1 commit 9b0700f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ async function addSentryToEntryProperty(
const filesToInject = [`./${userConfigFile}`];

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

0 comments on commit 9b0700f

Please sign in to comment.