diff --git a/.changeset/good-laws-marry.md b/.changeset/good-laws-marry.md new file mode 100644 index 00000000000..93a8ffcbb62 --- /dev/null +++ b/.changeset/good-laws-marry.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": patch +--- + +wait until app server is killed before starting a new app server diff --git a/packages/remix-dev/devServer_unstable/index.ts b/packages/remix-dev/devServer_unstable/index.ts index 89accea8855..4c95fcb9dea 100644 --- a/packages/remix-dev/devServer_unstable/index.ts +++ b/packages/remix-dev/devServer_unstable/index.ts @@ -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(); + p.kill("SIGTERM", { forceKillAfterTimeout: 1_000 }); + p.on("exit", channel.ok); + + await channel.result; };