stablyai/orca · error · Error
Invalid process CPU time: ${value}
Error message
Invalid process CPU time: ${value} What it means
parseCpuTimeSeconds parses the `time` column from ps output (format: [D-]HH:MM:SS or MM:SS). It splits on '-' for days, then on ':' for hours:minutes:seconds. If any component fails Number.isFinite after conversion, the format is unrecognized.
Source
Thrown at config/scripts/macos-computer-helper-owner-loss-metrics.mjs:26
}
export function median(values) {
const sorted = [...values].sort((left, right) => left - right)
const middle = Math.floor(sorted.length / 2)
return sorted.length % 2 === 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle]
}
export function percentile(values, fraction) {
const sorted = [...values].sort((left, right) => left - right)
return sorted[Math.max(0, Math.ceil(sorted.length * fraction) - 1)]
}
function parseCpuTimeSeconds(value) {
const [dayOrTime, clock] = value.includes('-') ? value.split('-', 2) : [null, value]
const days = dayOrTime === null ? 0 : Number(dayOrTime)
const parts = clock.split(':').map(Number)
if (!Number.isFinite(days) || parts.some((part) => !Number.isFinite(part))) {
throw new Error(`Invalid process CPU time: ${value}`)
}
const seconds = parts.pop() ?? 0
const minutes = parts.pop() ?? 0
const hours = parts.pop() ?? 0
return days * 86_400 + hours * 3_600 + minutes * 60 + seconds
}
export function processSnapshot(pid) {
const raw = execFileSync(
'ps',
['-o', 'rss=', '-o', 'time=', '-o', 'command=', '-p', String(pid)],
{ encoding: 'utf8' }
).trim()
const match = raw.match(/^(\d+)\s+(\S+)\s+(.+)$/)
if (!match) {
throw new Error(`Could not inspect process ${pid}: ${raw}`)
}
return {View on GitHub (pinned to 1136503c6a)
Solutions
- Pin LC_ALL=C when calling ps to ensure consistent POSIX formatting
- Log the raw ps `time=` value to inspect the actual format before parsing
- Handle the parse failure with a fallback (return 0 or skip the sample)
Example fix
// before: ps inherits shell locale, may produce non-POSIX time format
const raw = execFileSync('ps', ['-o', 'time=', '-p', String(pid)], { encoding: 'utf8' })
// after: pin locale to C for deterministic parsing
const raw = execFileSync('ps', ['-o', 'time=', '-p', String(pid)], {
encoding: 'utf8',
env: { ...process.env, LC_ALL: 'C' }
}) Defensive patterns
Strategy: try-catch
Validate before calling
// Pin locale for deterministic ps output before calling processSnapshot process.env.LC_ALL = 'C' process.env.LC_NUMERIC = 'C'
Try / catch
try {
const seconds = parseCpuTimeSeconds(rawTime)
} catch (error) {
if (error.message.includes('Invalid process CPU time')) {
// ps time format is unexpected — log raw value and use a fallback
console.warn('Unparseable CPU time:', rawTime, '— defaulting to 0')
return 0
}
throw error
} Prevention
- Pin LC_ALL=C in the environment when calling ps to ensure POSIX-standard time formatting
- Log the raw ps time column when parsing fails to diagnose format mismatches
- Handle edge cases: zombie processes may show no accumulated CPU time
When it happens
Trigger: The ps `time=` value for a PID does not match the expected D-HH:MM:SS or HH:MM:SS format. Causes: non-C locale changing number separators; a process with zero CPU time showing an unusual format; ps output truncation at column width.
Common situations: LC_ALL/LC_NUMERIC locale changes the decimal separator or time format; macOS version differences in ps time formatting; extremely long-running processes with day counts exceeding expected digits; zombie processes with no accumulated time.
Related errors
- Could not inspect process ${pid}: ${raw}
- Could not parse process identity for ${pid}
- Could not read watchdog child RSS for PID ${pid}
- Could not read CPU time for PID ${pid}
- Benchmark process group recovery failed before validation
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/bc0da89ce66bb987.
Report an issue: GitHub.