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

On Windows, Effect launches taskkill /T /F after Node has already observed a child exit. This adds redundant work to failing Git commands and can target a reused PID. See #2537.

Patch the shared Windows cleanup helper to complete its callback without launching taskkill when exitCode or signalCode is set. Live process trees keep the existing cleanup. The patch covers both source and shipped JavaScript for the existing @effect/platform-node-shared@4.0.2 dependency; no dependency versions change.

Verification:

  • Frozen-lockfile installation passed.
  • Existing process runner and VCS process suites: 43 tests passed.
  • A temporary probe using real child processes and simulated Windows taskkill dispatch passed for exited children, repeated kill, and live-child cleanup. Removing the guard makes the probe fail. This does not verify native Windows process-tree behavior.
  • Separate simplification and adversarial agent reviews found no actionable issues. No new test files or mock scaffolding added.

Independent Windows benchmark of the equivalent guard reduced failing Git command time from 267–273 ms to 29–32 ms. Exact-head native Windows verification remains outstanding.

Implemented by the original author; takeover review and verification by GPT-6.1-Sol through the Codex harness in T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 68e3e016-d273-401e-92fb-68b4f46f0831



      📥 Commits

      Reviewing files that changed from the base of the PR and between 0471bf997225d3a80aedd6191ba9804079705a3c and 8cee51e04035fa30d5ce0ae98a88006c3baf6485.




      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml



      📒 Files selected for processing (2)
      • patches/@effect__platform-node-shared@4.0.2.patch
      • pnpm-workspace.yaml



      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.





      📝 Walkthrough
      📝 Walkthrough
      📝 Walkthrough

      Walkthrough

      The patch changes the Windows taskkill helpers to skip PID-based tree cleanup when Node has observed the child leader exit. It also updates the cleanup documentation and registers the patch for @effect/platform-node-shared@4.0.2.

      Changes

      Windows cleanup

      Layer / File(s)Summary
      Guard cleanup by leader status
      patches/@effect__platform-node-shared@4.0.2.patch, pnpm-workspace.yaml
      The JavaScript and TypeScript helpers call onExit(null) and skip taskkill when exitCode or signalCode is non-null. Otherwise, they retain tree termination. The patch documents this behavior and the workspace config applies the patch to version 4.0.2.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Possibly related PRs

      • pingdotgg/t3code#16850: Applies an equivalent Windows taskkill helper change to @effect/platform-node-shared version 4.0.1.

      Suggested reviewers: juliusmarminge





      Merge Risk: ⚪ Minimal · up to 8cee5

      The cleanup change is mergeable after normal checks. Native Windows behavior for the rebuilt 4.0.2 package remains unverified, but no specific failure is established.

      Architecture Summary

      Architecture risk: 🔵 Low · up to 8cee5

      The change affects 2 systems.

      Changed systems: patches, pnpm-workspace.yaml

      Architecture concerns No architecture-level concerns identified.

      Review details

      Systems and components

      • observed — patches (service) was modified; 1 changed file maps to changed impact.
      • observed — pnpm-workspace.yaml (service) was modified; 1 changed file maps to changed impact.

      Before / after behavior

      • observed — Modified behavior in patches/@effect__platform-node-shared@4.0.2.patch: The JavaScript taskkill helper now checks whether exitCode or signalCode is non-null; if either is, it calls onExit(null) and skips taskkill. Otherwise, it retains the existing tree-termination command.
      • observed — Modified behavior in patches/@effect__platform-node-shared@4.0.2.patch: The Windows cleanup documentation now limits taskkill tree termination to when the leader is running and states that descendants outliving the leader are not reclaimed by PID-based cleanup.
      • observed — Modified behavior in patches/@effect__platform-node-shared@4.0.2.patch: The TypeScript taskkill helper now checks whether exitCode or signalCode is non-null; if either is, it calls onExit(null) and skips taskkill. Otherwise, it retains the existing tree-termination command.
      • observed — Modified behavior in pnpm-workspace.yaml: Adds a patched-dependency mapping for @effect/platform-node-shared@4.0.2 to its patch file.



      Pre-merge checks | Passed 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues checkPassedThe description links the related investigation and explains why this focused fix qualifies without separate approval evidence.
      Out of Scope Changes checkPassedThe changes remain within the stated scope: they patch Windows cleanup behavior, register the patch, and update related dependency metadata without changing POSIX behavior or dependency versions.
      Title checkPassedThe title is concise, conventional, and accurately identifies the Windows cleanup change for exited child processes.
      Description checkPassedThe description clearly covers the problem, implementation, verification results, limitations, issue reference, and agent attribution. It omits a separate Scope and approval heading, but it explains w…

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR





      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 8cee51e

      Macroscope's review found this PR approvable — This is a small, localized Windows process-cleanup fix that avoids stale-PID taskkill attempts while preserving live-process cleanup and POSIX behavior. The dependency patch, workspace registration, and lockfile updates consistently activate only this targeted change.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Tested on Windows 11 (Ryzen 7 5800X, git 2.55, Node 24.13). This patch is line for line the same change as #16850. I benchmarked that one on a fresh boot: 60 failing git config calls through NodeChildProcessSpawner, alternating unpatched and patched runs.

      runtaskkill launchesmain thread blocked in launcheswall time per git command
      unpatched1200.84 s267 ms
      patched00.16 s29 ms
      unpatched1200.85 s273 ms
      patched00.22 s32 ms

      Without the patch, each failing git command takes about 9 times as long, because the scope's release step waits for taskkill to finish. In 60 seconds of the desktop server's normal work, 64 of its 168 process launches were these taskkill calls.

      My comment on #16850 said this PR targeted 4.0.0-rc.115. It now patches 4.0.2, which main uses, and it merges cleanly. #16850 still patches 4.0.1 and now conflicts, so this is the one to land. #17707 removed the git launcher, but a failing git command still starts 6 processes, and 4 of them come from these two taskkill calls.

    5. juliusmarminge added labelsmacroscope-review

    6. juliusmarminge merged this243c999

    7. juliusmarminge closed this

    8. Follow-up from a Windows 11 24H2 host running T3 0.1.8-nightly.20261109.4433. Three kernel triage dumps on November 9 show bugcheck 0xEF CRITICAL_PROCESS_DIED, victim svchost.exe, and the terminating process object resolves to taskkill.exe. The crashes occurred at 6:36:42 PM, 7:37:20 PM and 8:07:32 PM Eastern. The triage dumps do not contain the killer parent process pages, so I cannot attribute these crashes to T3, a provider, or a project script yet. I am not uploading memory dumps.

      The exited-child guard from this PR is present in the installed server. Its shared NodeChildProcessSpawner helper still invokes:

      if (hasExited(childProcess)) { onExit(null); return; }
      NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], { windowsHide: true }, onExit);

      A temporary host-local IFEO block now records and refuses taskkill. At 8:55 PM it observed repeated /pid <pid> /T /F calls whose caller was the installed T3 Code (Nightly).exe, with its exact start identity checked. These are current cleanup calls, not evidence assigning the earlier crashes to T3.

      Installed-byte references:

      • server.asar SHA256 b4c72c49a28df8474d5888771454f7497997b32df571afeef36d25f573998717.
      • apps/server/dist/ManagedEndpointRuntime-dymI0Epp.mjs SHA256 b60c46ae7d4937eabdb6bc121f55db03d9ff2e6473658561bd23d3e5e2e2fbcd, helper at character offset 4598661.

      Separately, a project-owned QA tree selector had a reproducible stale-parent defect. Windows retains a child's numeric parent PID after the parent exits. A later process reusing that PID was treated as the ancestor of an older boot process. A pure fixture reproduced selection of wininit -> services -> svchost under a newer QA root. Rejecting links where the child predates the current parent fixes that project selector. This does not establish how native taskkill selected any crash victim.

      The remaining native cleanup concern is broader than the exited-child guard: a live root alone does not validate every descendant edge. A process handle and creation-time check for each selected process, refusal of critical/unknown processes, and individual termination avoid relying on an unchecked numeric PID tree. I have not tested native /T against system processes and will not do so. The local block remains while the exact caller investigation and permanent repair continue.

Sign in to join this conversation.