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: keep process running when fail to load config in restarting server #2510

Merged
merged 1 commit into from
Mar 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ModuleNode } from './moduleGraph'
import { Update } from 'types/hmrPayload'
import { CLIENT_DIR } from '../constants'
import { RollupError } from 'rollup'
import { prepareError } from './middlewares/error'
import match from 'minimatch'

export const debugHmr = createDebugger('vite:hmr')
Expand Down Expand Up @@ -410,9 +411,20 @@ async function readModifiedFile(file: string): Promise<string> {
}

async function restartServer(server: ViteDevServer) {
// @ts-ignore
global.__vite_start_time = Date.now()
let newServer = null
try {
newServer = await createServer(server.config.inlineConfig)
} catch (err) {
server.ws.send({
type: 'error',
err: prepareError(err)
})
return
}

await server.close()
;(global as any).__vite_start_time = Date.now()
const newServer = await createServer(server.config.inlineConfig)
for (const key in newServer) {
if (key !== 'app') {
// @ts-ignore
Expand Down