fix(dev): multiple server instances being created when editing config too quickly (#3835)

pull/3837/head
Divyansh Singh 8 months ago committed by GitHub
parent 75115f4f82
commit 729a890669
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -20,6 +20,8 @@ if (root) {
argv.root = root argv.root = root
} }
let restartPromise: Promise<void> | undefined
if (!command || command === 'dev') { if (!command || command === 'dev') {
if (argv.force) { if (argv.force) {
delete argv.force delete argv.force
@ -28,8 +30,16 @@ if (!command || command === 'dev') {
const createDevServer = async () => { const createDevServer = async () => {
const server = await createServer(root, argv, async () => { const server = await createServer(root, argv, async () => {
if (!restartPromise) {
restartPromise = (async () => {
await server.close() await server.close()
await createDevServer() await createDevServer()
})().finally(() => {
restartPromise = undefined
})
}
return restartPromise
}) })
await server.listen() await server.listen()
logVersion(server.config.logger) logVersion(server.config.logger)

Loading…
Cancel
Save