Unverified Commit 4dfe831b authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add project directory rename/remove handling (#44911)

parent d7307cff
#!/usr/bin/env node #!/usr/bin/env node
import arg from 'next/dist/compiled/arg/index.js' import arg from 'next/dist/compiled/arg/index.js'
import { existsSync, watchFile } from 'fs'
import { startServer } from '../server/lib/start-server' import { startServer } from '../server/lib/start-server'
import { getPort, printAndExit } from '../server/lib/utils' import { getPort, printAndExit } from '../server/lib/utils'
import * as Log from '../build/output/log' import * as Log from '../build/output/log'
...@@ -18,11 +17,15 @@ import cluster from 'cluster' ...@@ -18,11 +17,15 @@ import cluster from 'cluster'
import { Telemetry } from '../telemetry/storage' import { Telemetry } from '../telemetry/storage'
import loadConfig from '../server/config' import loadConfig from '../server/config'
import { findPagesDir } from '../lib/find-pages-dir' import { findPagesDir } from '../lib/find-pages-dir'
import { fileExists } from '../lib/file-exists'
import Watchpack from 'next/dist/compiled/watchpack'
import stripAnsi from 'next/dist/compiled/strip-ansi'
let isTurboSession = false let isTurboSession = false
let sessionStopHandled = false let sessionStopHandled = false
let sessionStarted = Date.now() let sessionStarted = Date.now()
let dir: string let dir: string
let unwatchConfigFiles: () => void
const handleSessionStop = async () => { const handleSessionStop = async () => {
if (sessionStopHandled) return if (sessionStopHandled) return
...@@ -65,14 +68,37 @@ const handleSessionStop = async () => { ...@@ -65,14 +68,37 @@ const handleSessionStop = async () => {
true true
) )
telemetry.flushDetached('dev', dir) telemetry.flushDetached('dev', dir)
} catch (err) { } catch (_) {
console.error(err) // errors here aren't actionable so don't add
// noise to the output
} }
process.exit(0) process.exit(0)
} }
process.on('SIGINT', handleSessionStop) if (cluster.isMaster) {
process.on('SIGTERM', handleSessionStop) process.on('SIGINT', handleSessionStop)
process.on('SIGTERM', handleSessionStop)
} else {
process.on('SIGINT', () => process.exit(0))
process.on('SIGTERM', () => process.exit(0))
}
function watchConfigFiles(dirToWatch: string) {
if (unwatchConfigFiles) {
unwatchConfigFiles()
}
const wp = new Watchpack()
wp.watch({ files: CONFIG_FILES.map((file) => path.join(dirToWatch, file)) })
wp.on('change', (filename) => {
console.log(
`\n> Found a change in ${path.basename(
filename
)}. Restart the server to see the changes in effect.`
)
})
return () => wp.close()
}
const nextDev: CliCommand = async (argv) => { const nextDev: CliCommand = async (argv) => {
const validArgs: arg.Spec = { const validArgs: arg.Spec = {
...@@ -121,10 +147,11 @@ const nextDev: CliCommand = async (argv) => { ...@@ -121,10 +147,11 @@ const nextDev: CliCommand = async (argv) => {
process.exit(0) process.exit(0)
} }
dir = getProjectDir(args._[0]) dir = getProjectDir(process.env.NEXT_PRIVATE_DEV_DIR || args._[0])
unwatchConfigFiles = watchConfigFiles(dir)
// Check if pages dir exists and warn if not // Check if pages dir exists and warn if not
if (!existsSync(dir)) { if (!(await fileExists(dir, 'directory'))) {
printAndExit(`> No such directory exists as the project root: ${dir}`) printAndExit(`> No such directory exists as the project root: ${dir}`)
} }
...@@ -392,12 +419,173 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit ...@@ -392,12 +419,173 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit
// this is a temporary solution until we can fix the memory leaks. // this is a temporary solution until we can fix the memory leaks.
// the logic for the worker killing itself is in `packages/next/server/lib/start-server.ts` // the logic for the worker killing itself is in `packages/next/server/lib/start-server.ts`
if (!process.env.__NEXT_DISABLE_MEMORY_WATCHER && cluster.isMaster) { if (!process.env.__NEXT_DISABLE_MEMORY_WATCHER && cluster.isMaster) {
cluster.fork() let config: NextConfig
cluster.on('exit', (worker) => {
if (worker.exitedAfterDisconnect) { const setupFork = (env?: Parameters<typeof cluster.fork>[0]) => {
cluster.fork() const startDir = dir
let shouldFilter = false
cluster.fork({
...env,
FORCE_COLOR: '1',
})
// since errors can start being logged from the fork
// before we detect the project directory rename
// attempt suppressing them long enough to check
const filterForkErrors = (chunk: Buffer, fd: 'stdout' | 'stderr') => {
const cleanChunk = stripAnsi(chunk + '')
if (
cleanChunk.match(
/(ENOENT|Module build failed|Module not found|Cannot find module)/
)
) {
if (startDir === dir) {
try {
// check if start directory is still valid
const result = findPagesDir(
startDir,
!!config.experimental?.appDir
)
shouldFilter = !Boolean(result.pagesDir || result.appDir)
} catch (_) {
shouldFilter = true
}
}
if (shouldFilter || startDir !== dir) {
shouldFilter = true
return
}
}
process[fd].write(chunk)
}
for (const workerId in cluster.workers) {
cluster.workers[workerId]?.process.stdout?.on('data', (chunk) => {
filterForkErrors(chunk, 'stdout')
})
cluster.workers[workerId]?.process.stderr?.on('data', (chunk) => {
filterForkErrors(chunk, 'stderr')
})
}
}
const handleClusterExit = () => {
const callback = async (worker: cluster.Worker) => {
// ignore if we killed the worker
if ((worker as any).killed) return
// TODO: we should track how many restarts are
// occurring and how long in-between them
if (worker.exitedAfterDisconnect) {
setupFork()
} else if (!sessionStopHandled) {
await handleSessionStop()
process.exit(1)
}
}
cluster.addListener('exit', callback)
return () => cluster.removeListener('exit', callback)
}
let clusterExitUnsub = handleClusterExit()
cluster.settings.stdio = ['ipc', 'pipe', 'pipe']
setupFork()
config = await loadConfig(PHASE_DEVELOPMENT_SERVER, dir)
const handleProjectDirRename = (newDir: string) => {
clusterExitUnsub()
for (const workerId in cluster.workers) {
try {
// @ts-expect-error custom field
cluster.workers[workerId].killed = true
cluster.workers[workerId]!.process.kill('SIGKILL')
} catch (_) {}
}
process.chdir(newDir)
// @ts-expect-error type is incorrect
cluster.settings.cwd = newDir
cluster.settings.exec = cluster.settings.exec?.replace(dir, newDir)
setupFork({
...Object.keys(process.env).reduce((newEnv, key) => {
newEnv[key] = process.env[key]?.replace(dir, newDir)
return newEnv
}, {} as typeof process.env),
NEXT_PRIVATE_DEV_DIR: newDir,
})
clusterExitUnsub = handleClusterExit()
}
const parentDir = path.join('/', dir, '..')
const watchedEntryLength = parentDir.split('/').length + 1
const previousItems = new Set()
const wp = new Watchpack({
ignored: (entry: string) => {
// watch only one level
return !(entry.split('/').length <= watchedEntryLength)
},
})
wp.watch({ directories: [parentDir], startTime: 0 })
wp.on('aggregated', () => {
const knownFiles = wp.getTimeInfoEntries()
const newFiles: string[] = []
let hasPagesApp = false
// if the dir still exists nothing to check
try {
const result = findPagesDir(dir, !!config.experimental?.appDir)
hasPagesApp = Boolean(result.pagesDir || result.appDir)
} catch (err) {
// if findPagesDir throws validation error let this be
// handled in the dev-server itself in the fork
if ((err as any).message?.includes('experimental')) {
return
}
}
// try to find new dir introduced
if (previousItems.size) {
for (const key of knownFiles.keys()) {
if (!previousItems.has(key)) {
newFiles.push(key)
}
}
previousItems.clear()
}
for (const key of knownFiles.keys()) {
previousItems.add(key)
}
if (hasPagesApp) {
return
}
// if we failed to find the new dir it may have been moved
// to a new parent directory which we can't track as easily
// so exit gracefully
try {
const result = findPagesDir(
newFiles[0],
!!config.experimental?.appDir
)
hasPagesApp = Boolean(result.pagesDir || result.appDir)
} catch (_) {}
if (hasPagesApp && newFiles.length === 1) {
Log.info(
`Detected project directory rename, restarting in new location`
)
handleProjectDirRename(newFiles[0])
watchConfigFiles(newFiles[0])
dir = newFiles[0]
} else { } else {
process.exit(1) Log.error(
`Project directory could not be found, restart Next.js in your new directory`
)
process.exit(0)
} }
}) })
} else { } else {
...@@ -440,16 +628,6 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit ...@@ -440,16 +628,6 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit
}) })
} }
} }
for (const CONFIG_FILE of CONFIG_FILES) {
watchFile(path.join(dir, CONFIG_FILE), (cur: any, prev: any) => {
if (cur.size > 0 || prev.size > 0) {
console.log(
`\n> Found a change in ${CONFIG_FILE}. Restart the server to see the changes in effect.`
)
}
})
}
} }
export { nextDev } export { nextDev }
...@@ -1924,6 +1924,37 @@ export default abstract class Server<ServerOptions extends Options = Options> { ...@@ -1924,6 +1924,37 @@ export default abstract class Server<ServerOptions extends Options = Options> {
this.customErrorNo404Warn() this.customErrorNo404Warn()
} }
if (!result) {
// this can occur when a project directory has been moved/deleted
// which is handled in the parent process in development
if (this.renderOpts.dev) {
return {
type: 'html',
// wait for dev-server to restart before refreshing
body: RenderResult.fromStatic(
`
<pre>missing required error components, refreshing...</pre>
<script>
async function check() {
const res = await fetch(location.href).catch(() => ({}))
if (res.status === 200) {
location.reload()
} else {
setTimeout(check, 1000)
}
}
check()
</script>`
),
}
}
throw new WrappedBuildError(
new Error('missing required error components')
)
}
try { try {
return await this.renderToResponseWithComponents( return await this.renderToResponseWithComponents(
{ {
...@@ -1934,7 +1965,7 @@ export default abstract class Server<ServerOptions extends Options = Options> { ...@@ -1934,7 +1965,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
err, err,
}, },
}, },
result! result
) )
} catch (maybeFallbackError) { } catch (maybeFallbackError) {
if (maybeFallbackError instanceof NoFallbackError) { if (maybeFallbackError instanceof NoFallbackError) {
......
...@@ -1443,7 +1443,12 @@ export default class DevServer extends Server { ...@@ -1443,7 +1443,12 @@ export default class DevServer extends Server {
// patched global in memory, creating a memory leak. // patched global in memory, creating a memory leak.
this.restorePatchedGlobals() this.restorePatchedGlobals()
return super.findPageComponents({ pathname, query, params, isAppPath }) return await super.findPageComponents({
pathname,
query,
params,
isAppPath,
})
} catch (err) { } catch (err) {
if ((err as any).code !== 'ENOENT') { if ((err as any).code !== 'ENOENT') {
throw err throw err
......
...@@ -20,5 +20,5 @@ exports[`ReactRefreshLogBox app scss syntax errors 2`] = ` ...@@ -20,5 +20,5 @@ exports[`ReactRefreshLogBox app scss syntax errors 2`] = `
Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id) Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id)
> 1 | button { font-size: 5px; } > 1 | button { font-size: 5px; }
| ^" | ^"
`; `;
import fs from 'fs-extra'
import webdriver from 'next-webdriver'
import { check, findPort, hasRedbox } from 'next-test-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { createNext } from 'e2e-utils'
import stripAnsi from 'strip-ansi'
describe('Project Directory Renaming', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
export default function Page() {
return <p>hello world</p>
}
`,
},
skipStart: true,
})
next.forcedPort = (await findPort()) + ''
await next.start()
})
afterAll(() => next.destroy())
it('should detect project dir rename and restart', async () => {
const browser = await webdriver(next.url, '/')
await browser.eval('window.beforeNav = 1')
let newTestDir = `${next.testDir}-renamed`
await fs.move(next.testDir, newTestDir)
next.testDir = newTestDir
await check(
() => stripAnsi(next.cliOutput),
/Detected project directory rename, restarting in new location/
)
await check(async () => {
return (await browser.eval('window.beforeNav')) === 1 ? 'pending' : 'done'
}, 'done')
expect(await hasRedbox(browser, false)).toBe(false)
try {
// should still HMR correctly
await next.patchFile(
'pages/index.js',
(
await next.readFile('pages/index.js')
).replace('hello world', 'hello again')
)
await check(async () => {
if (!(await browser.eval('!!window.next'))) {
await browser.refresh()
}
return browser.eval('document.documentElement.innerHTML')
}, /hello again/)
} finally {
await next.patchFile(
'pages/index.js',
(
await next.readFile('pages/index.js')
).replace('hello again', 'hello world')
)
}
})
})
...@@ -2,6 +2,7 @@ import path from 'path' ...@@ -2,6 +2,7 @@ import path from 'path'
import { createNext, FileRef } from 'e2e-utils' import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base' import { NextInstance } from 'test/lib/next-modes/base'
import { check } from 'next-test-utils' import { check } from 'next-test-utils'
import stripAnsi from 'strip-ansi'
describe('app-dir create root layout', () => { describe('app-dir create root layout', () => {
const isDev = (global as any).isNextDev const isDev = (global as any).isNextDev
...@@ -41,10 +42,10 @@ describe('app-dir create root layout', () => { ...@@ -41,10 +42,10 @@ describe('app-dir create root layout', () => {
) )
await check( await check(
() => next.cliOutput.slice(outputIndex), () => stripAnsi(next.cliOutput.slice(outputIndex)),
/did not have a root layout/ /did not have a root layout/
) )
expect(next.cliOutput.slice(outputIndex)).toMatch( expect(stripAnsi(next.cliOutput.slice(outputIndex))).toMatch(
'Your page app/route/page.js did not have a root layout. We created app/layout.js and app/head.js for you.' 'Your page app/route/page.js did not have a root layout. We created app/layout.js and app/head.js for you.'
) )
...@@ -101,10 +102,10 @@ describe('app-dir create root layout', () => { ...@@ -101,10 +102,10 @@ describe('app-dir create root layout', () => {
) )
await check( await check(
() => next.cliOutput.slice(outputIndex), () => stripAnsi(next.cliOutput.slice(outputIndex)),
/did not have a root layout/ /did not have a root layout/
) )
expect(next.cliOutput.slice(outputIndex)).toInclude( expect(stripAnsi(next.cliOutput.slice(outputIndex))).toInclude(
'Your page app/(group)/page.js did not have a root layout. We created app/(group)/layout.js and app/(group)/head.js for you.' 'Your page app/(group)/page.js did not have a root layout. We created app/(group)/layout.js and app/(group)/head.js for you.'
) )
...@@ -163,10 +164,10 @@ describe('app-dir create root layout', () => { ...@@ -163,10 +164,10 @@ describe('app-dir create root layout', () => {
) )
await check( await check(
() => next.cliOutput.slice(outputIndex), () => stripAnsi(next.cliOutput.slice(outputIndex)),
/did not have a root layout/ /did not have a root layout/
) )
expect(next.cliOutput.slice(outputIndex)).toInclude( expect(stripAnsi(next.cliOutput.slice(outputIndex))).toInclude(
'Your page app/(group)/route/second/inner/page.js did not have a root layout. We created app/(group)/route/second/layout.js and app/(group)/route/second/head.js for you.' 'Your page app/(group)/route/second/inner/page.js did not have a root layout. We created app/(group)/route/second/layout.js and app/(group)/route/second/head.js for you.'
) )
...@@ -224,10 +225,10 @@ describe('app-dir create root layout', () => { ...@@ -224,10 +225,10 @@ describe('app-dir create root layout', () => {
) )
await check( await check(
() => next.cliOutput.slice(outputIndex), () => stripAnsi(next.cliOutput.slice(outputIndex)),
/did not have a root layout/ /did not have a root layout/
) )
expect(next.cliOutput.slice(outputIndex)).toInclude( expect(stripAnsi(next.cliOutput.slice(outputIndex))).toInclude(
'Your page app/page.tsx did not have a root layout. We created app/layout.tsx and app/head.tsx for you.' 'Your page app/page.tsx did not have a root layout. We created app/layout.tsx and app/head.tsx for you.'
) )
...@@ -281,7 +282,7 @@ describe('app-dir create root layout', () => { ...@@ -281,7 +282,7 @@ describe('app-dir create root layout', () => {
}) })
await expect(next.start()).rejects.toThrow('next build failed') await expect(next.start()).rejects.toThrow('next build failed')
expect(next.cliOutput).toInclude( expect(stripAnsi(next.cliOutput)).toInclude(
"page.js doesn't have a root layout. To fix this error, make sure every page has a root layout." "page.js doesn't have a root layout. To fix this error, make sure every page has a root layout."
) )
await next.destroy() await next.destroy()
......
...@@ -2,6 +2,7 @@ import { createNext, FileRef } from 'e2e-utils' ...@@ -2,6 +2,7 @@ import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base' import { NextInstance } from 'test/lib/next-modes/base'
import { fetchViaHTTP, File, nextBuild } from 'next-test-utils' import { fetchViaHTTP, File, nextBuild } from 'next-test-utils'
import { join } from 'path' import { join } from 'path'
import stripAnsi from 'strip-ansi'
const appDir = join(__dirname, './app') const appDir = join(__dirname, './app')
const pagePath = 'pages/index.jsx' const pagePath = 'pages/index.jsx'
...@@ -50,7 +51,7 @@ describe('Configurable runtime for pages and API routes', () => { ...@@ -50,7 +51,7 @@ describe('Configurable runtime for pages and API routes', () => {
const res = await fetchViaHTTP(next.url, `/api/edge`) const res = await fetchViaHTTP(next.url, `/api/edge`)
expect(res.status).toEqual(200) expect(res.status).toEqual(200)
expect(next.cliOutput).not.toInclude('error') expect(next.cliOutput).not.toInclude('error')
expect(next.cliOutput).toInclude( expect(stripAnsi(next.cliOutput)).toInclude(
`warn - /pages/api/edge provided runtime 'experimental-edge'. It can be updated to 'edge' instead.` `warn - /pages/api/edge provided runtime 'experimental-edge'. It can be updated to 'edge' instead.`
) )
}) })
...@@ -66,7 +67,7 @@ describe('Configurable runtime for pages and API routes', () => { ...@@ -66,7 +67,7 @@ describe('Configurable runtime for pages and API routes', () => {
const res = await fetchViaHTTP(next.url, `/`) const res = await fetchViaHTTP(next.url, `/`)
expect(res.status).toEqual(200) expect(res.status).toEqual(200)
expect(next.cliOutput).not.toInclude('error') expect(next.cliOutput).not.toInclude('error')
expect(next.cliOutput).toInclude( expect(stripAnsi(next.cliOutput)).toInclude(
`warn - You are using an experimental edge runtime, the API might change.` `warn - You are using an experimental edge runtime, the API might change.`
) )
}) })
...@@ -82,7 +83,7 @@ describe('Configurable runtime for pages and API routes', () => { ...@@ -82,7 +83,7 @@ describe('Configurable runtime for pages and API routes', () => {
await next.start() await next.start()
const res = await fetchViaHTTP(next.url, `/`) const res = await fetchViaHTTP(next.url, `/`)
expect(res.status).toEqual(200) expect(res.status).toEqual(200)
expect(next.cliOutput).toInclude( expect(stripAnsi(next.cliOutput)).toInclude(
`error - Page /pages provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.` `error - Page /pages provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.`
) )
expect(next.cliOutput).not.toInclude('warn') expect(next.cliOutput).not.toInclude('warn')
...@@ -121,7 +122,7 @@ describe('Configurable runtime for pages and API routes', () => { ...@@ -121,7 +122,7 @@ describe('Configurable runtime for pages and API routes', () => {
}) })
expect(output.code).toBe(1) expect(output.code).toBe(1)
expect(output.stderr).not.toContain(`Build failed`) expect(output.stderr).not.toContain(`Build failed`)
expect(output.stderr).toContain( expect(stripAnsi(output.stderr)).toContain(
`Error: Page / provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.` `Error: Page / provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.`
) )
}) })
......
...@@ -656,9 +656,9 @@ function expectModuleNotFoundProdError( ...@@ -656,9 +656,9 @@ function expectModuleNotFoundProdError(
output = context.logs.output output = context.logs.output
) { ) {
const moduleNotSupportedMessage = getUnsupportedModule(moduleName) const moduleNotSupportedMessage = getUnsupportedModule(moduleName)
expect(output).not.toContain(moduleNotSupportedMessage) expect(stripAnsi(output)).not.toContain(moduleNotSupportedMessage)
const moduleNotFoundMessage = getModuleNotFound(moduleName) const moduleNotFoundMessage = getModuleNotFound(moduleName)
expect(output).toContain(moduleNotFoundMessage) expect(stripAnsi(output)).toContain(moduleNotFoundMessage)
} }
function expectModuleNotFoundDevError( function expectModuleNotFoundDevError(
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
nextBuild, nextBuild,
} from 'next-test-utils' } from 'next-test-utils'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import stripAnsi from 'strip-ansi'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
let appPort: number let appPort: number
...@@ -26,9 +27,9 @@ function runTests({ isDev }) { ...@@ -26,9 +27,9 @@ function runTests({ isDev }) {
expect(await hasRedbox(browser, true)).toBe(true) expect(await hasRedbox(browser, true)).toBe(true)
expect(await getRedboxHeader(browser)).toBe('Failed to compile') expect(await getRedboxHeader(browser)).toBe('Failed to compile')
expect(await getRedboxSource(browser)).toBe(`./pages/index.js:3\n${msg}`) expect(await getRedboxSource(browser)).toBe(`./pages/index.js:3\n${msg}`)
expect(stderr).toContain(msg) expect(stripAnsi(stderr)).toContain(msg)
} else { } else {
expect(stderr).toContain(msg) expect(stripAnsi(stderr)).toContain(msg)
} }
}) })
} }
......
import {
check,
findPort,
killApp,
launchApp,
renderViaHTTP,
} from 'next-test-utils'
import { join } from 'path'
import fs from 'fs-extra'
import stripAnsi from 'strip-ansi'
describe('Project Directory Delete Handling', () => {
it('should gracefully exit on project dir delete', async () => {
const appDir = join(__dirname, 'app')
const appPort = await findPort()
await fs.ensureDir(join(appDir, 'pages'))
await fs.writeFile(
join(appDir, 'pages', 'index.js'),
`
export default function Page() {
return <p>hello world</p>
}
`
)
let output = ''
const app = await launchApp(appDir, appPort, {
onStdout(msg) {
output += msg
},
onStderr(msg) {
output += msg
},
})
expect(await renderViaHTTP(appPort, '/')).toContain('hello world')
await fs.remove(appDir)
await check(
() => stripAnsi(output),
/Project directory could not be found, restart Next\.js in your new directory/
)
try {
await killApp(app)
} catch (_) {}
})
})
...@@ -70,7 +70,7 @@ export class NextDevInstance extends NextInstance { ...@@ -70,7 +70,7 @@ export class NextDevInstance extends NextInstance {
this.childProcess.on('close', (code, signal) => { this.childProcess.on('close', (code, signal) => {
if (this.isStopping) return if (this.isStopping) return
if (code || signal) { if (code || signal) {
throw new Error( require('console').error(
`next dev exited unexpectedly with code/signal ${code || signal}` `next dev exited unexpectedly with code/signal ${code || signal}`
) )
} }
......
...@@ -110,7 +110,7 @@ export class NextStartInstance extends NextInstance { ...@@ -110,7 +110,7 @@ export class NextStartInstance extends NextInstance {
this.childProcess.on('close', (code, signal) => { this.childProcess.on('close', (code, signal) => {
if (this.isStopping) return if (this.isStopping) return
if (code || signal) { if (code || signal) {
throw new Error( require('console').error(
`next start exited unexpectedly with code/signal ${ `next start exited unexpectedly with code/signal ${
code || signal code || signal
}` }`
......
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