mihomo-party-org/clash-party · warning
Failed to parse process list JSON:
Error message
Failed to parse process list JSON:
What it means
In cleanupWindowsNamedPipes, the app runs a PowerShell/CIM query on Windows to enumerate mihomo processes, then JSON.parses stdout. When stdout is empty, truncated, or not JSON (localized output, older PowerShell returning text), JSON.parse throws and this warning is logged before falling back to fallbackTextParsing(stdout). Functionality continues via the text parser.
Source
Thrown at src/main/core/process.ts:76
`powershell -NoProfile -Command "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Get-Process | Where-Object {$_.ProcessName -like '*mihomo*'} | Select-Object Id,ProcessName | ConvertTo-Json"`,
{ encoding: 'utf8' }
)
if (stdout.trim()) {
managerLogger.info(`Found potential pipe-blocking processes: ${stdout}`)
try {
const processes = JSON.parse(stdout)
const processArray = Array.isArray(processes) ? processes : [processes]
for (const proc of processArray) {
const pid = proc.Id
if (pid && pid !== process.pid) {
await terminateProcess(pid)
}
}
} catch (parseError) {
managerLogger.warn('Failed to parse process list JSON:', parseError)
await fallbackTextParsing(stdout)
}
}
} catch (error) {
managerLogger.warn('Failed to check mihomo processes:', error)
}
await new Promise((resolve) => setTimeout(resolve, 1000))
} catch (error) {
managerLogger.error('Windows named pipe cleanup failed:', error)
}
}
async function terminateProcess(pid: number): Promise<void> {
try {
process.kill(pid, 0)
process.kill(pid, 'SIGTERM')
managerLogger.info(`Terminated process ${pid} to free pipe`)View on GitHub (pinned to 911e090537)
Solutions
- No action needed — fallbackTextParsing handles it; treat the warning as a signal the JSON path failed.
- Upgrade Windows PowerShell (v3+) so ConvertTo-Json is available and output is stable JSON.
- Harden the query to emit explicit JSON (e.g. wrap results in an array and force ConvertTo-Json -Compress) and trim/validate stdout before parsing.
Example fix
// before
const list = JSON.parse(stdout)
// after
let list = []
try {
list = JSON.parse(stdout.trim() || '[]')
} catch {
list = parseProcessText(stdout) // deterministic text fallback
} Defensive patterns
Strategy: fallback
Validate before calling
const trimmed = stdout?.trim()
if (!trimmed || !trimmed.startsWith('{') && !trimmed.startsWith('[')) {
return parseProcessText(stdout) // skip JSON path entirely
} Type guard
const isProcessListJson = (v: unknown): v is { Id?: number }[] =>
Array.isArray(v) && v.every((x) => typeof x === 'object' && x !== null) Try / catch
try {
const list = JSON.parse(stdout)
if (!isProcessListJson(list)) throw new Error('unexpected shape')
} catch (parseError) {
managerLogger.warn('Failed to parse process list JSON:', parseError)
await fallbackTextParsing(stdout)
} Prevention
- Force stable machine-readable output: `ConvertTo-Json -Compress -InputObject @(...)` with explicit culture.
- Prefer CIM/CMDLET query paths available on the minimum supported Windows version, or use Native APIs.
- Keep the text fallback tested so JSON failures never break pipe cleanup.
When it happens
Trigger: JSON.parse(stdout) throws inside the process-list branch: empty stdout from ConvertTo-Json on empty result sets, PowerShell version < 3 without ConvertTo-Json, non-English locale output, or stderr noise mixed into the stream.
Common situations: Windows 7 / PowerShell 2.0 environments; `taskkill`-style query returning 'No results'; console codepage mangling output; the query matched zero mihomo processes so JSON is empty/blank.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Executable file not found in zip: ${exeFile}
- Translation not ready
- Core is not running, restarting core instead of hot reload
AI-assisted analysis of mihomo-party-org/clash-party@911e090537 (2026-08-30).
Data as JSON: /api/errors/1d4cfd921d169f1e.
Report an issue: GitHub.