Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): skip Windows cleanup for exited child processes #16007

MergedAlb11747(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/16007/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 61 additions and 0 deletions.

x
0 of 3 viewed, 3 left
60 additions and 0 deletionspatches/@effect__platform-node-shared@4.0.2.patchAdded
View file
@@ -0,0 +1,60 @@
+diff --git a/dist/NodeChildProcessSpawner.js b/dist/NodeChildProcessSpawner.js
+--- a/dist/NodeChildProcessSpawner.js
++++ b/dist/NodeChildProcessSpawner.js
+@@ -44,9 +44,17 @@
+ return false;
+ }
+ };
+-const taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], {
+- windowsHide: true
+-}, onExit);
++const taskkill = (childProcess, onExit = () => {}) => {
++ // Once Node observes the leader's exit, taskkill /T cannot reclaim orphaned
++ // descendants through its PID, which may be reused. Skip stale-PID cleanup.
++ if (childProcess.exitCode !== null || childProcess.signalCode !== null) {
++ onExit(null);
++ return;
++ }
++ NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], {
++ windowsHide: true
++ }, onExit);
++};
+ const make = /*#__PURE__*/Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+diff --git a/src/NodeChildProcessSpawner.ts b/src/NodeChildProcessSpawner.ts
+--- a/src/NodeChildProcessSpawner.ts
++++ b/src/NodeChildProcessSpawner.ts
+@@ -19,7 +19,9 @@
+ * `forceKillAfter`, the wait is limited to one second and never escalates.
+ * With it, cleanup may take the configured duration plus a final one-second