Skip to content

Commit

Permalink
fix(nextjs): Reverse order of checks for instrumenting server (#5828)
Browse files Browse the repository at this point in the history
As it stands right now, when we check whether or not to require `instrumentServer`, our check short-circuits if the code is running on vercel. This is a problem, because the first run of `isBuild()` causes a side effect (it sets an env var) which then enables all future runs, so without that initial run, future runs fail. This reverses the order of the check, so that `isBuild()` will always run.
  • Loading branch information
lobsterkatie committed Sep 27, 2022
1 parent d1f0b60 commit 0cfda74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/nextjs/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export {
// deployments, because the current method of doing the wrapping a) crashes Next 12 apps deployed to Vercel and
// b) doesn't work on those apps anyway. We also don't do it during build, because there's no server running in that
// phase.)
if (!isVercel && !isBuild()) {
if (!isBuild() && !isVercel) {
// Dynamically require the file because even importing from it causes Next 12 to crash on Vercel.
// In environments where the JS file doesn't exist, such as testing, import the TS file.
try {
Expand Down

0 comments on commit 0cfda74

Please sign in to comment.