stablyai/orca · error · Error
${result.stderr || 'PowerShell process enumeration failed'}
Error message
${result.stderr || 'PowerShell process enumeration failed'} What it means
readWindowsProcesses runs a PowerShell CIM query (Get-CimInstance Win32_Process) via spawnSync to enumerate processes on Windows. It throws when spawnSync returns a non-zero status, surfacing result.stderr (or a generic fallback). readProcessRows only selects this path when process.platform === 'win32', so the error is Windows-only. A non-zero status means PowerShell itself failed to run the query, distinct from a spawn error (which would appear on result.error and surface differently).
Source
Thrown at config/scripts/idle-cpu-process-sampling.mjs:66
function readUnixProcesses() {
const stdout = execFileSync('ps', ['-axo', 'pid=,ppid=,pcpu=,rss=,cputime=,command='], {
encoding: 'utf8',
env: { ...process.env, LC_ALL: 'C', LANG: 'C' },
maxBuffer: 20 * 1024 * 1024
})
return parseUnixProcesses(stdout)
}
function readWindowsProcesses() {
const script =
'Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,WorkingSetSize,CommandLine | ConvertTo-Json -Compress'
const result = spawnSync('powershell.exe', ['-NoProfile', '-Command', script], {
encoding: 'utf8',
maxBuffer: 20 * 1024 * 1024
})
if (result.status !== 0) {
throw new Error(result.stderr || 'PowerShell process enumeration failed')
}
const parsed = JSON.parse(result.stdout || '[]')
const entries = Array.isArray(parsed) ? parsed : [parsed]
return entries.map((entry) => ({
pid: Number(entry.ProcessId),
ppid: Number(entry.ParentProcessId),
percentCpu: 0,
cpuTimeSeconds: null,
rssBytes: Number(entry.WorkingSetSize) || 0,
command: String(entry.CommandLine || '')
}))
}
export function readProcessRows() {
return process.platform === 'win32' ? readWindowsProcesses() : readUnixProcesses()
}
export function descendantsOf(rows, rootPid) {View on GitHub (pinned to 1136503c6a)
Solutions
- Confirm powershell.exe resolves on PATH (where powershell) on the host.
- Inspect result.stderr in the thrown error for the PowerShell-level failure.
- Verify the WinMgmt service is running (Get-Service WinMgmt) and the CIM repository is healthy.
- On non-Windows hosts this code path never runs — confirm process.platform is not unexpectedly 'win32'.
Example fix
// before
const result = spawnSync('powershell.exe', ['-NoProfile', '-Command', script], { encoding: 'utf8', maxBuffer: 20 * 1024 * 1024 })
if (result.status !== 0) {
throw new Error(result.stderr || 'PowerShell process enumeration failed')
}
// after — surface spawn errors too, and keep a readable status
if (result.error) {
throw result.error
}
if (result.status !== 0) {
throw new Error(`PowerShell process enumeration failed (status ${result.status}): ${result.stderr}`)
} Defensive patterns
Strategy: try-catch
Validate before calling
const psOk = (() => {
try { spawnSync('powershell.exe', ['-NoProfile', '-Command', 'exit 0']); return true }
catch { return false }
})()
if (process.platform === 'win32' && !psOk) throw new Error('powershell.exe required on PATH') Try / catch
try {
rows = readProcessRows()
} catch (err) {
if (process.platform !== 'win32') throw err
log.warn(`Windows process enumeration failed: ${err.message}; falling back to empty rows`)
rows = []
} Prevention
- On Windows CI, confirm powershell.exe is on PATH and WinMgmt is running before sampling.
- Treat a non-zero PowerShell status as a host/environment problem, not a sampling bug.
When it happens
Trigger: powershell.exe is absent or not on PATH; PowerShell execution policy or profile blocks the command; the WinMgmt/CIM service is stopped or corrupted; the CIM provider returns an error to stderr.
Common situations: Minimal/hardened Windows CI image without PowerShell; WMI repository corruption; group policy restricting script execution; antivirus intercepting PowerShell.
Related errors
- PowerShell did not return signature JSON.
- PowerShell returned malformed signature JSON: ${error.messag
- PowerShell wrote to stderr while checking signature:\n${resu
- PowerShell signature check failed with exit code ${result.st
- ${result.detail} No PATH changes were made.
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/79a4abbd21b646c5.
Report an issue: GitHub.