fix: don't reopen browser on restart

closes #4001
pull/3901/merge
Divyansh Singh 4 months ago
parent 0fc70e2d0c
commit d837e82bc8

@ -28,25 +28,32 @@ if (!command || command === 'dev') {
argv.optimizeDeps = { force: true }
}
const createDevServer = async () => {
const server = await createServer(root, argv, async () => {
if (!restartPromise) {
restartPromise = (async () => {
await server.close()
await createDevServer()
})().finally(() => {
restartPromise = undefined
})
}
const open = argv.open
delete argv.open
return restartPromise
})
const createDevServer = async (isRestart = true) => {
const server = await createServer(
root,
!isRestart ? { ...argv, open } : argv,
async () => {
if (!restartPromise) {
restartPromise = (async () => {
await server.close()
await createDevServer()
})().finally(() => {
restartPromise = undefined
})
}
return restartPromise
}
)
await server.listen()
logVersion(server.config.logger)
server.printUrls()
bindShortcuts(server, createDevServer)
}
createDevServer().catch((err) => {
createDevServer(false).catch((err) => {
createLogger().error(
`${c.red(`failed to start server. error:`)}\n${err.message}\n${err.stack}`
)

Loading…
Cancel
Save