Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev): ignore errors when killing already dead processes #6773

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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