fix(windows): fall back to Get-CimInstance when wmic is missing (Win11 24H2+)#7
Open
yunjeongiya wants to merge 1 commit into
Open
Conversation
wmic is deprecated and absent by default on Windows 11 24H2+ / Server 2025.
ProcessTree.fromWMIC() then returns an empty tree, so zclean reports
"0 zombies" and never cleans anything on those machines. CI only runs
ubuntu/macos, so this Windows path was never exercised.
- Add ProcessTree.fromCIM(): enumerate via Get-CimInstance Win32_Process
(PowerShell), producing the same {pid,ppid,cmd,mem,age,startTime} shape as
fromWMIC/fromPS. Invoked with execFileSync + -EncodedCommand (no shell, no
quoting issues); $ProgressPreference=SilentlyContinue keeps stderr clean.
- Add ProcessTree.fromWindows(): try wmic first (keeps the fast path where it
still exists), fall back to fromCIM() when wmic is missing or yields nothing.
- build() uses fromWindows() on win32; non-Windows path unchanged.
- Silence the "'wmic' is not recognized" stderr leak in fromWMIC().
- Tests: platform-aware fromWindows/fromCIM cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6.
Problem
wmicis gone by default on Windows 11 24H2+ / Server 2025.ProcessTree.fromWMIC()then returns an empty tree, so zclean reports "0 zombies" and never cleans anything on those machines. CI runs onlyubuntu-latest/macos-latest, so this path was never exercised.Change
ProcessTree.fromCIM()— enumerate viaGet-CimInstance Win32_Process(PowerShell), producing the exact same{pid, ppid, cmd, mem, age, startTime}shape asfromWMIC()/fromPS().execFileSync(no shell) +-EncodedCommand(no quoting issues).$ProgressPreference='SilentlyContinue'keeps stderr clean.ProcessTree.fromWindows()— tryfromWMIC()first (keeps the existing fast path where wmic is still present), fall back tofromCIM()when wmic is missing or yields nothing.build()now callsfromWindows()on win32. The non-Windows (fromPS) path is unchanged.'wmic' is not recognizedstderr leak infromWMIC()so the fallback probe is quiet.fromWindows/fromCIMcases (cross-platform "doesn't throw" + win32-only live-enumeration assertions).Verification (Windows 11, build 26200, no wmic)
node --testis green except the pre-existing unix-onlyfromPSlive test (which passes on the ubuntu/macos CI).Notes
wmicas the primary Windows path to preserve current behaviour/perf; happy to make CIM the default and drop wmic entirely if you'd prefer (wmic is end-of-life).windows-latestto the CI matrix — it would have caught this. ThefromPSlive test would need a unix guard first.