Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): should close server after create new server #12379

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,6 @@ async function restartServer(server: ViteDevServer) {
const { port: prevPort, host: prevHost } = server.config.server
const shortcutsOptions: BindShortcutsOptions = server._shortcutsOptions
const oldUrls = server.resolvedUrls
await server.close()

let inlineConfig = server.config.inlineConfig
if (server._forceOptimizeOnRestart) {
Expand All @@ -834,9 +833,12 @@ async function restartServer(server: ViteDevServer) {
server.config.logger.error(err.message, {
timestamp: true,
})
server.config.logger.error('server restart failed', { timestamp: true })
return
}

await server.close()

// prevent new server `restart` function from calling
newServer._restartPromise = server._restartPromise

Expand Down