TypeScript
fix(server): skip Windows cleanup for exited child processes (#16007)
Alb11747243c9994d047
diff --git a/patches/@[email protected] b/patches/@[email protected]new file mode 100644index 00000000000..f08c7d096bc--- /dev/null+++ b/patches/@[email protected]@@ -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+ * wait after `SIGKILL`. Zombie descendants can consume either full bound. On+- * Windows, `taskkill` terminates the tree and only the leader's exit is awaited.++ * Windows, `taskkill` terminates the tree while the leader is running and only++ * the leader's exit is awaited. Descendants that outlive the leader are not++ * reclaimed by PID-based cleanup.+ *+ * POSIX cleanup targets a numeric process-group ID. If the group disappears+ * and its ID is reused before cleanup, an unrelated group may be signalled.+@@ -99,13 +101,20 @@+ const taskkill = (+ childProcess: NodeChildProcess.ChildProcess,+ onExit: (error: NodeChildProcess.ExecException | null) => void = () => {}+-) =>++) => {++ // 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 = Effect.gen(function*() {+ const fs = yield* FileSystem.FileSystemdiff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 7e6efe07503..f37cdc0ca1d 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -144,6 +144,7 @@ packageExtensionsChecksum: sha256-FYDaKefjFcda1+vgiq8yMpZC4ehE5CyLi/bsCGLgTtY=patchedDependencies:'@clerk/[email protected]': b8b22ab733de5bea846ad9e88046c10582352fe9ad86f314f368b2a823f0f281+ '@effect/[email protected]': 4efe73732a53b7d7bdbd9a9263eed06310fc387f870ef4a5e66429e9d1fd7cd9'@effect/[email protected]': 595b7d26fb635caba9c3d39fcb189bb78a000192f8d3b60ead7174b310d1ade9'@expo/[email protected]': 90fa980e8b6480631fb2fbb04559834e3c612db40c550cd828f11be297d8d760'@ff-labs/[email protected]': 8956d6ed6938a1bce69b2d0b067ff258dd9ca753c5bbe7006f7b68f760ea3ad2@@ -611,7 +612,7 @@ importers:version: 4.0.2([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])([email protected])'@effect/platform-node-shared':specifier: 4.0.2- version: 4.0.2([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])+ version: 4.0.2(patch_hash=4efe73732a53b7d7bdbd9a9263eed06310fc387f870ef4a5e66429e9d1fd7cd9)([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])'@ff-labs/fff-node':specifier: 0.11.0version: 0.11.0(patch_hash=8956d6ed6938a1bce69b2d0b067ff258dd9ca753c5bbe7006f7b68f760ea3ad2)@@ -13838,7 +13839,7 @@ snapshots:transitivePeerDependencies:- encoding- '@effect/[email protected]([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])':+ '@effect/[email protected](patch_hash=4efe73732a53b7d7bdbd9a9263eed06310fc387f870ef4a5e66429e9d1fd7cd9)([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])':dependencies:'@types/ws': 8.18.2effect: 4.0.2(patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688)@@ -13849,7 +13850,7 @@ snapshots:'@effect/[email protected]([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])([email protected])':dependencies:- '@effect/platform-node-shared': 4.0.2([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])+ '@effect/platform-node-shared': 4.0.2(patch_hash=4efe73732a53b7d7bdbd9a9263eed06310fc387f870ef4a5e66429e9d1fd7cd9)([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])effect: 4.0.2(patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688)redis: 6.2.1undici: 8.11.2diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex edbfad72d8e..3ffe4a41ee4 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -288,6 +288,7 @@ patchedDependencies:[email protected]: patches/[email protected][email protected]: patches/[email protected]"@clerk/[email protected]": patches/@[email protected]+ "@effect/[email protected]": patches/@[email protected]"@effect/[email protected]": patches/@[email protected]"@expo/[email protected]": patches/@[email protected][email protected]: patches/[email protected]