Skip to content

fix: Worker fails to spawn on Windows 11 25H2+ (WMIC removed) #785

@bivlked

Description

@bivlked

Bug Description

Worker daemon fails to start on Windows 11 25H2 (Build 26200+) with error:

[ERROR] [SYSTEM] Failed to spawn worker daemon

The root cause is that wmic.exe has been completely removed from Windows 11 25H2, but the code in ProcessManager.ts uses WMIC to spawn the daemon process.

Environment

  • OS: Windows 11 Pro for Workstation 25H2 (Build 26200.7309)
  • claude-mem version: 9.0.6
  • Claude Code version: 2.1.3
  • Node.js: v24.13.0
  • Bun: 1.3.6

Steps to Reproduce

  1. Install claude-mem on Windows 11 25H2+
  2. Start Claude Code
  3. Worker fails to start with timeout error:
    UserPromptSubmit operation blocked by hook:
    [bun "${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs" hook claude-code session-init]:
    Hook error: Error: Worker did not become ready within 15 seconds. (port 37777)
    

Root Cause Analysis

1. WMIC is removed in Windows 11 25H2

Microsoft deprecated WMIC in Windows 10 and completely removed it in Windows 11 25H2:

PS> Test-Path 'C:\Windows\System32\wbem\wmic.exe'
False

PS> wmic os get caption
wmic: The term 'wmic' is not recognized as a name of a cmdlet...

2. Current code uses WMIC for daemon spawn

File: src/services/infrastructure/ProcessManager.ts (lines 287-306)

if (isWindows) {
  // Use WMIC to spawn a process that's independent of the parent console
  const execPath = process.execPath;
  const script = scriptPath;
  const command = `wmic process call create "\\"${execPath}\\" \\"${script}\\" --daemon"`;

  try {
    execSync(command, { stdio: 'ignore', windowsHide: true });
    return 0;
  } catch {
    return undefined;  // <-- Silent failure, no error logged
  }
}

3. Additional issue: Uses Node.js instead of Bun

Even if WMIC worked, process.execPath returns the Node.js path, but the worker requires Bun because it uses bun:sqlite:

Error: Cannot find module 'bun:sqlite'
Require stack:
- C:\Users\...\plugin\scripts\worker-service.cjs

Solution

Replace WMIC with PowerShell Start-Process and use Bun instead of Node.js:

if (isWindows) {
  // Use PowerShell Start-Process to spawn a hidden background process
  // WMIC is deprecated and removed in Windows 11 25H2+
  // Worker uses bun:sqlite so must be run with bun, not node
  const bunPath = process.env.USERPROFILE
    ? `${process.env.USERPROFILE}\\.bun\\bin\\bun.exe`
    : 'bun.exe';
  const script = scriptPath;

  // Build environment variables string for PowerShell
  const envVars = Object.entries(env)
    .filter(([key]) => key.startsWith('CLAUDE_MEM_'))
    .map(([key, value]) => `$env:${key}='${value}'`)
    .join('; ');

  // PowerShell command: Start-Process with -WindowStyle Hidden
  const psCommand = `${envVars}; Start-Process -FilePath '${bunPath}' -ArgumentList '${script}','--daemon' -WindowStyle Hidden`;
  const command = `powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "${psCommand.replace(/"/g, '\\"')}"`;

  try {
    execSync(command, { stdio: 'ignore', windowsHide: true });
    return 0;
  } catch {
    return undefined;
  }
}

Why PowerShell Start-Process?

Method Console Popup Independent Process Windows 11 25H2
wmic process call create No Yes Removed
child_process.spawn with detached: true Yes (popup) Yes Works
Start-Process -WindowStyle Hidden No Yes Works

PowerShell Start-Process with -WindowStyle Hidden is the best alternative:

  • No console popup
  • Process is independent of parent
  • Works on all Windows versions (PowerShell is always available)

Testing

After applying the patch:

$ bun run worker:start
{"continue":true,"suppressOutput":true,"status":"ready"}

$ bun run worker:status
Worker is running
  PID: 11052
  Port: 37777
  Started: 2026-01-23T14:33:13.571Z

$ curl http://127.0.0.1:37777/api/health
{"status":"ok","initialized":true,"mcpReady":true}

$ curl http://127.0.0.1:37777/api/stats
{"database":{"observations":548,"sessions":13,"summaries":222}}

Related Issues

Impact

This bug affects all users on:

  • Windows 11 version 25H2 (Build 26100+)
  • Windows 11 Insider builds
  • Future Windows versions

As Windows 11 25H2 is the current stable release, this is a critical issue for Windows users.

Suggested Fix Location

File: src/services/infrastructure/ProcessManager.ts
Function: spawnDaemon() (lines 275-323)

I can submit a PR with this fix if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions