Skip to content

fix(win): detect wmic once, add useGwmi option - #195

Merged
soyuka merged 2 commits into
mainfrom
fix/wmic-detection
Oct 13, 2026
Merged

soyuka merged 2 commits into
mainfrom
fix/wmic-detection

Conversation

@soyuka

@soyuka soyuka commented Oct 13, 2026

Copy link
Copy Markdown
Owner

The wmic check in lib/stats.js called spawn('wmic', fn), which throws ERR_INVALID_ARG_TYPE synchronously, so gwmi was always used and the check ran on every call. It now checks for %SystemRoot%\System32\wbem\WMIC.exe once (no process spawned) and caches the result. useGwmi: true skips the detection.

Tested on Windows Server 2025 (no WMIC), node 24.13 with --throw-deprecation: no DEP0190, gwmi path ~260ms per call in both modes. wmic path covered by the mocked test only.

Closes #191

The spawn based wmic check always threw ERR_INVALID_ARG_TYPE, so
gwmi was used every time and wmic was never picked. Check for
WMIC.exe once instead, and let useGwmi skip the detection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pidusage on Windows results in child-process shell option deprecation warning

1 participant