Unverified Commit 45030d62 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix `next dev` failing for app when `__NEXT_DISABLE_MEMORY_WATCHER` is set (#49056)

This env should only affect the teardown & restart process, instead of
the `useWorkers` option. This also solves the problem of running `next
dev` on StackBlitz (which has the env var set:
https://github.com/vercel/next.js/issues/48964#issuecomment-1528569879).

Closes #48964.
parent 58e5c780
......@@ -211,7 +211,8 @@ const nextDev: CliCommand = async (argv) => {
allowRetry,
isDev: true,
hostname: host,
useWorkers: !process.env.__NEXT_DISABLE_MEMORY_WATCHER,
// This is required especially for app dir.
useWorkers: true,
}
if (args['--turbo']) {
......@@ -318,7 +319,7 @@ const nextDev: CliCommand = async (argv) => {
const setupFork = async (newDir?: string) => {
// if we're using workers we can auto restart on config changes
if (!devServerOptions.useWorkers && devServerTeardown) {
if (process.env.__NEXT_DISABLE_MEMORY_WATCHER && devServerTeardown) {
Log.info(
`Detected change, manual restart required due to '__NEXT_DISABLE_MEMORY_WATCHER' usage`
)
......@@ -410,12 +411,6 @@ const nextDev: CliCommand = async (argv) => {
true
)
}
if (config.experimental?.appDir && !devServerOptions.useWorkers) {
Log.error(
`Disabling dev workers is not supported with appDir enabled`
)
}
}
await setupFork()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment