Skip to content

fix(agent): derive the Windows OS name from the registry, not WMI - #135

Merged
mikhailm-coder merged 1 commit into
masterfrom
hotfix/win-os-name-no-wmi
Sep 15, 2026
Merged

mikhailm-coder merged 1 commit into
masterfrom
hotfix/win-os-name-no-wmi

Conversation

@mikhailm-coder

Copy link
Copy Markdown

Problem

os.Name's win32 branch runs a synchronous require('win-wmi').query('ROOT\CIMV2', "SELECT * FROM Win32_OperatingSystem", …). That call blocks the agent's single microstack thread with no timeout, and os.Name is 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. A CurrentBuild >= 22000 check corrects the known-stale Windows 11 ProductName (which still reads "Windows 10 …"). win32 branch only; linux/darwin/freebsd untouched. win-wmi now has zero references in this file.

Registry was originally swapped for WMI upstream (2021) because ProductName goes 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

  • The OS-name string is a display/search label only: MeshCentral console, CSV export, the optional OS search box, and stored on the Mongo node doc. Verified across the flamingo repos (MeshCentral, OpenFrame backend, frontend) that nothing parses or branches on its format. OpenFrame's own device OS comes from the client's registration (osType), not this value.
  • os.Name has one non-display use — a ChromeOS check in service-manager.js — but it's on the Linux/Upstart path, untouched by a win32-only change.
  • An independent code-review pass confirmed ret is always a string on every path (missing registry values throw → clean Windows (UNKNOWN) fallback), the edge cases (parseInt NaN, 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:

  • Healthy Windows 10 / 11 / Server: device shows the correct OS string.
  • Windows with WMI stalled (the failing case): agent connects, authenticates, and the core comes up with no 20-minute watchdog exit.
  • macOS / Linux: OS string unchanged.

CU-86akhfjyx

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

🦩 Flamingo Code Review

1 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.

  • Review the new commits — the commits added since this review
  • Review the whole diff again — ignoring what was already reviewed

Prefer typing? Comment @flamingo-review, or @flamingo-review full. To review every push on this pull request, add the flamingo-review-always label.

React 👍/👎 on inline comments to teach the reviewer.

Started 2026-09-15 11:04 UTC · updated 2026-09-15 11:04 UTC · workflow run

Comment thread microscript/ILibDuktape_ScriptContainer.c
@mikhailm-coder
mikhailm-coder merged commit d59128d into master Sep 15, 2026
7 checks passed
@mikhailm-coder
mikhailm-coder deleted the hotfix/win-os-name-no-wmi branch September 15, 2026 11:35
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.

2 participants