Skip to content

Commit bd79438

Browse files
committed
fix(windows): skip stale child process cleanup
1 parent 61eb4af commit bd79438

3 files changed

Lines changed: 63 additions & 3 deletions

File tree

‎patches/@[email protected]‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
diff --git a/dist/NodeChildProcessSpawner.js b/dist/NodeChildProcessSpawner.js
2+
--- a/dist/NodeChildProcessSpawner.js
3+
+++ b/dist/NodeChildProcessSpawner.js
4+
@@ -44,9 +44,16 @@
5+
return false;
6+
}
7+
};
8+
-const taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], {
9+
- windowsHide: true
10+
-}, onExit);
11+
+const taskkill = (childProcess, onExit = () => {}) => {
12+
+ // An exited leader's PID cannot safely identify its former Windows tree.
13+
+ if (childProcess.exitCode !== null || childProcess.signalCode !== null) {
14+
+ onExit(null);
15+
+ return;
16+
+ }
17+
+ NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], {
18+
+ windowsHide: true
19+
+ }, onExit);
20+
+};
21+
const make = /*#__PURE__*/Effect.gen(function* () {
22+
const fs = yield* FileSystem.FileSystem;
23+
const path = yield* Path.Path;
24+
diff --git a/src/NodeChildProcessSpawner.ts b/src/NodeChildProcessSpawner.ts
25+
--- a/src/NodeChildProcessSpawner.ts
26+
+++ b/src/NodeChildProcessSpawner.ts
27+
@@ -19,7 +19,9 @@
28+
* `forceKillAfter`, the wait is limited to one second and never escalates.
29+
* With it, cleanup may take the configured duration plus a final one-second
30+
* wait after `SIGKILL`. Zombie descendants can consume either full bound. On
31+
- * Windows, `taskkill` terminates the tree and only the leader's exit is awaited.
32+
+ * Windows, `taskkill` terminates the tree while the leader is running and only
33+
+ * the leader's exit is awaited. Descendants that outlive the leader are not
34+
+ * reclaimed by PID-based cleanup.
35+
*
36+
* POSIX cleanup targets a numeric process-group ID. If the group disappears
37+
* and its ID is reused before cleanup, an unrelated group may be signalled.
38+
@@ -98,13 +100,19 @@
39+
const taskkill = (
40+
childProcess: NodeChildProcess.ChildProcess,
41+
onExit: (error: NodeChildProcess.ExecException | null) => void = () => {}
42+
-) =>
43+
+) => {
44+
+ // An exited leader's PID cannot safely identify its former Windows tree.
45+
+ if (childProcess.exitCode !== null || childProcess.signalCode !== null) {
46+
+ onExit(null)
47+
+ return
48+
+ }
49+
NodeChildProcess.execFile(
50+
"taskkill",
51+
["/pid", String(childProcess.pid!), "/T", "/F"],
52+
{ windowsHide: true },
53+
onExit
54+
)
55+
+}
56+
57+
const make = Effect.gen(function*() {
58+
const fs = yield* FileSystem.FileSystem

‎pnpm-lock.yaml‎

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ packageExtensions:
283283
vite-plus: "catalog:"
284284

285285
patchedDependencies:
286+
286287
287288
288289

0 commit comments

Comments
 (0)