Skip to content

Commit

Permalink
fix(dev): ignore errors when killing already dead processes
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Jul 5, 2023
1 parent 96b3a32 commit 9173524
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-coins-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

ignore errors when killing already dead processes
17 changes: 10 additions & 7 deletions packages/remix-dev/devServer_unstable/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import pidtree from "pidtree";
let isWindows = process.platform === "win32";

export let kill = async (pid: number) => {
try {
let cmd = isWindows
? ["taskkill", "/F", "/PID", pid.toString()]
: ["kill", "-9", pid.toString()];
await execa(cmd[0], cmd.slice(1));
} catch (error) {
throw new Error(`Failed to kill process ${pid}: ${error}`);
if (isWindows) {
await execa("taskkill", ["/F", "/PID", pid.toString()]).catch((error) => {
// taskkill 128 -> the process is already dead
if (error.exitCode !== 128) throw error;
});
return;
}
await execa("kill", ["-9", pid.toString()]).catch((error) => {
// process is already dead
if (!/No such process/.test(error.message)) throw error;
});
};

let isAlive = (pid: number) => {
Expand Down

0 comments on commit 9173524

Please sign in to comment.