coleam00/Archon · error · DetachedRunOwnerUnavailableError
owner returned an invalid PID
Error message
owner returned an invalid PID
What it means
parseOwnerResponse() successfully parsed JSON but the 'pid' field is missing, not a number, not an integer, or <= 0. Since the whole point of the exchange is to learn the owner's process id for cancellation, an unusable pid makes the run effectively uncontrollable, so DetachedRunOwnerUnavailableError is thrown with reason 'owner returned an invalid PID'.
Source
Thrown at packages/cli/src/utils/detached-run-control.ts:313
};
}
function parseOwnerResponse(runId: string, raw: string): number {
let parsed: unknown;
try {
parsed = JSON.parse(raw);
} catch {
throw new DetachedRunOwnerUnavailableError(runId, 'owner returned an invalid response');
}
if (
typeof parsed !== 'object' ||
parsed === null ||
!('pid' in parsed) ||
typeof parsed.pid !== 'number' ||
!Number.isInteger(parsed.pid) ||
parsed.pid <= 0
) {
throw new DetachedRunOwnerUnavailableError(runId, 'owner returned an invalid PID');
}
return parsed.pid;
}
/** Ask the live exact-run owner for an opaque termination lease. */
export function requestDetachedRunStop(runId: string): Promise<DetachedRunStopTarget> {
const path = detachedRunControlPath(runId);
return new Promise((resolve, reject) => {
const socket = createConnection(path);
let response = '';
let settled = false;
const fail = (detail: string): void => {
if (settled) return;
settled = true;
socket.destroy();
reject(new DetachedRunOwnerUnavailableError(runId, detail));
};
const onEnd = (): void => {View on GitHub (pinned to 0773b97458)
Solutions
- Check the Archon version owning the run and align it with your CLI version (protocol mismatch is the usual cause).
- Stop the misbehaving owner and restart the run to get a fresh, correct owner.
- If reproducible, report it with the raw owner response — the schema sent by the owner should always include a positive integer pid.
Defensive patterns
Strategy: type-guard
Validate before calling
function hasValidPid(raw: string): boolean {
try {
const o: unknown = JSON.parse(raw);
return typeof o === 'object' && o !== null && 'pid' in o
&& Number.isInteger((o as { pid: unknown }).pid) && (o as { pid: number }).pid > 0;
} catch { return false; }
} Type guard
function isOwnerPidPayload(v: unknown): v is { pid: number } {
return typeof v === 'object' && v !== null
&& 'pid' in v
&& typeof (v as { pid: unknown }).pid === 'number'
&& Number.isInteger((v as { pid: number }).pid)
&& (v as { pid: number }).pid > 0;
} Try / catch
try {
const pid = await getDetachedRunOwnerPid(runId);
} catch (err) {
if (err instanceof DetachedRunOwnerUnavailableError && err.reason === 'owner returned an invalid PID') {
console.error('Owner replied with unusable pid (version/protocol mismatch?); restart the run.');
} else throw err;
} Prevention
- Align owner and client Archon versions so the {pid:number} schema matches.
- Reject/stub owners that return alternate field names; restart the run cleanly.
- Log the raw payload (no secrets) when diagnosing protocol mismatches.
When it happens
Trigger: The owner endpoint returns valid JSON whose pid field fails typeof number / Number.isInteger / > 0 checks.
Common situations: A protocol-version mismatch where the owner replies {"processId": ...} or omits pid; a stub/mock or third-party process bound to the socket returning a different schema; a corrupted owner build.
Related errors
- owner returned an invalid response
- Detached run control endpoint is already owned: ${path}
- Detached run control endpoint is already owned: ${endpointPa
- Refusing detached run control because process ${String(proce
- Corrupt commands JSON for codebase ${id}: unable to parse st
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/c2f88586fb0bc79b.
Report an issue: GitHub.