Skip to content

Commit

Permalink
fix(dev): wait until app server is killed before starting new app server
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed May 3, 2023
1 parent 0e2763f commit 8b182d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-laws-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

wait until app server is killed before starting a new app server
13 changes: 5 additions & 8 deletions packages/remix-dev/devServer_unstable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,10 @@ let relativePath = (file: string) => path.relative(process.cwd(), file);

let kill = async (p?: execa.ExecaChildProcess) => {
if (p === undefined) return;
// `execa`'s `kill` is not reliable on windows
if (process.platform === "win32") {
await execa("taskkill", ["/pid", String(p.pid), "/f", "/t"]);
return;
}

// wait one tick of the event loop so that we guarantee app server gets killed before proceeding
p.kill("SIGTERM", { forceKillAfterTimeout: 0 });
await new Promise((resolve) => setTimeout(resolve, 0));
let channel = Channel.create<void>();
p.kill("SIGTERM", { forceKillAfterTimeout: 1_000 });
p.on("exit", channel.ok);

await channel.result;
};

0 comments on commit 8b182d3

Please sign in to comment.