Skip to content

Commit

Permalink
prevent server from restarting while restart is in progress (sveltejs…
Browse files Browse the repository at this point in the history
  • Loading branch information
DveMac committed May 27, 2020
1 parent b80346e commit c9a62fa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/api/dev.ts
Expand Up @@ -246,7 +246,7 @@ class Watcher extends EventEmitter {
const restart = () => {
this.crashed = false;

ports.wait(this.port)
return ports.wait(this.port)
.then((() => {
this.emit('ready', <ReadyEvent>{
port: this.port,
Expand Down Expand Up @@ -310,11 +310,14 @@ class Watcher extends EventEmitter {
};

if (this.proc) {
if (this.restarting) return;
this.restarting = true;
this.proc.removeListener('exit', emitFatal);
this.proc.kill();
this.proc.on('exit', () => {
this.proc.on('exit', async () => {
start_server();
restart();
await restart();
this.restarting = false;
});
} else {
start_server();
Expand Down

0 comments on commit c9a62fa

Please sign in to comment.