Skip to content

Commit

Permalink
Restore NEXT_PHASE
Browse files Browse the repository at this point in the history
`process.env.NEXT_PHASE` was moved in vercel#20900 to be set during `staticCheckSpan.traceAsyncFn`. I believe this to be a mistake, the NEXT_PHASE should be set earlier in the code execution.

On a personal note, this impacts an application I am developing where we rely on the environment variable `NEXT_PHASE` to be set but is `undefined` when we check it.
  • Loading branch information
jbraithwaite committed Sep 8, 2021
1 parent 1389339 commit ac4acf2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/next/build/index.ts
Expand Up @@ -681,6 +681,9 @@ export default async function build(
? require.resolve('./worker')
: require.resolve('./utils')
let infoPrinted = false

process.env.NEXT_PHASE = PHASE_PRODUCTION_BUILD

const staticWorkers = new Worker(staticWorker, {
timeout: timeout * 1000,
onRestart: (method, [arg], attempts) => {
Expand Down Expand Up @@ -741,8 +744,6 @@ export default async function build(
hasSsrAmpPages,
hasNonStaticErrorPage,
} = await staticCheckSpan.traceAsyncFn(async () => {
process.env.NEXT_PHASE = PHASE_PRODUCTION_BUILD

const runtimeEnvConfig = {
publicRuntimeConfig: config.publicRuntimeConfig,
serverRuntimeConfig: config.serverRuntimeConfig,
Expand Down

0 comments on commit ac4acf2

Please sign in to comment.