fix(agent): derive the Windows OS name from the registry, not WMI - #135
Merged
Merged
Conversation
os.Name's win32 branch ran a synchronous require('win-wmi').query for
Win32_OperatingSystem on every control-channel connect. That call blocks
the single microstack thread with no timeout; when the WMI provider host
(WmiPrvSE) can't register with DCOM, it never returns, the chain watchdog
(ILibChain_WATCHDOG_TIMEOUT, 10 min) exits the process after two stuck
cycles, SCM restarts it ~5s later, and it wedges again -- a ~20-minute
crash loop. On a Windows RDS host this ran 50+ times, saturated the
Service Control Manager, and deadlocked Remote Desktop until a reboot.
Read the OS name from the registry instead (ProductName + CurrentBuild +
DisplayVersion), which cannot hang. A CurrentBuild >= 22000 check corrects
the known-stale Windows 11 ProductName. win32 branch only; linux/darwin/
freebsd unchanged. The value is a display/search label (MeshCentral
console + coreinfo.osdesc); no consumer parses its format.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦩 Flamingo Code Review1 finding(s) — 0 action required · 1 recommended · 0 informational Mode: advisory · 1 defect(s) outside any rule Inline comments: 1 new Need another pass? Commits pushed after this review are not reviewed automatically.
Prefer typing? Comment React 👍/👎 on inline comments to teach the reviewer. Started 2026-09-15 11:04 UTC · updated 2026-09-15 11:04 UTC · workflow run |
denys-gif
approved these changes
Sep 15, 2026
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.
Problem
os.Name's win32 branch runs a synchronousrequire('win-wmi').query('ROOT\CIMV2', "SELECT * FROM Win32_OperatingSystem", …). That call blocks the agent's single microstack thread with no timeout, andos.Nameis evaluated on every control-channel connect (before auth).When the Windows WMI provider host (
WmiPrvSE) can't register with DCOM — host-level RPC/DCOM/SCM saturation — the query never returns. The chain watchdog (ILibChain_WATCHDOG_TIMEOUT= 600000 ms) then exits the process (exit(254)) after two stuck cycles, SCM restarts it ~5 s later, and it wedges again: a ~20-minute crash loop. On a customer Windows RDS terminal server this ran 50+ times, and the restart churn plus the concurrent 120 s SCM transaction timeouts saturated the Service Control Manager and deadlocked Remote Desktop until an out-of-band reboot. It's not a crash (no WER/dump), which is why it logged only SCM 7031.Fix
Remove WMI from the win32 branch and derive the OS name from the registry (
ProductName+CurrentBuild+DisplayVersion) — registry reads are fast local calls that can't hang. ACurrentBuild >= 22000check corrects the known-stale Windows 11ProductName(which still reads "Windows 10 …"). win32 branch only; linux/darwin/freebsd untouched.win-wminow has zero references in this file.Registry was originally swapped for WMI upstream (2021) because
ProductNamegoes stale on modern Windows — the build-number check addresses exactly that, so accuracy is preserved without the hang. The only cosmetic change on a healthy box: the string drops the "Microsoft " prefix ("Microsoft Windows 11 Pro" → "Windows 11 Pro"); the build number is identical.Scope / safety
osType), not this value.os.Namehas one non-display use — a ChromeOS check inservice-manager.js— but it's on the Linux/Upstart path, untouched by a win32-only change.retis always a string on every path (missing registry values throw → cleanWindows (UNKNOWN)fallback), the edge cases (parseIntNaN, the 22000 threshold, Server SKUs, Win10 LTSC) are handled, and the escaping / brace balance are intact.Testing
Not buildable in this environment — needs the standard agent build matrix and a canary:
CU-86akhfjyx
🤖 Generated with Claude Code