coleam00/Archon · error · Error
Failed to wait for workflow run: ${err.message}
Error message
Failed to wait for workflow run: ${err.message} What it means
`archon workflow wait <runId>` polls until a run reaches a terminal state; if waiting throws, the CLI logs and either emits `{ok:false, runId, action:'wait', error}` JSON (in `--json` mode it never throws, matching the get/write contract) or re-throws 'Failed to wait for workflow run: <message>'.
Source
Thrown at packages/cli/src/commands/workflow.ts:3615
let resolvedId: string;
try {
resolvedId = await resolveRunIdArg(runId, cwd);
result = await waitForRunAttention(resolvedId, {
// No timeout by default: a wait that ends on its own clock would answer a
// question only the run can answer.
...(timeoutSeconds === undefined ? {} : { deadlineMs: timeoutSeconds * 1000 }),
onAttached: observedStatus => announceWaitAttached(resolvedId, observedStatus, json),
});
} catch (error) {
const err = error as Error;
getLog().error({ err, runId }, 'cli.workflow_wait_failed');
// In --json mode never throw — emit one parseable {ok:false} line (same contract
// as `get` and the write commands) so a parsing agent always gets JSON.
if (json) {
await writeJsonLine({ ok: false, runId, action: 'wait', error: err.message });
return 1;
}
throw new Error(`Failed to wait for workflow run: ${err.message}`);
}
if (result.kind === 'not_found') {
if (json) {
await writeJsonLine({ ok: false, runId, action: 'wait', error: 'not_found' });
} else {
console.log(formatWaitOutcome(resolvedId, result));
}
return 1;
}
if (json) {
await writeJsonLine({
ok: true,
action: 'wait',
runId: resolvedId,
result: result.kind,
...(result.kind === 'attention' ? { attention: result.attention } : {}),View on GitHub (pinned to 0773b97458)
Solutions
- Retry the wait command — it is idempotent and will re-poll.
- Verify DB connectivity if waits fail repeatedly (network, DSN, locks).
- Use `archon workflow get <runId> --json` to check whether the run exists and its state.
- In scripts, use `--json` mode and handle the `{ok:false, action:'wait'}` line instead of parsing thrown errors.
Example fix
// before
const code = await waitCommand(runId); // throws on failure
// after
const code = await waitCommand(runId, { json: true });
// parse emitted line: { ok: false, runId, action: 'wait', error } and handle explicitly Defensive patterns
Strategy: try-catch
Validate before calling
// confirm the run exists before waiting
const status = await getRunStatus(runId);
if (status.kind === 'not_found') throw new Error(`Run ${runId} not found`); Type guard
function isNotFound(r: { kind: string }): r is { kind: 'not_found' } {
return r.kind === 'not_found';
} Try / catch
try {
const result = await waitForRun(runId);
} catch (err) {
const e = err as Error;
if (json) {
await writeJsonLine({ ok: false, runId, action: 'wait', error: e.message });
return 1;
}
throw new Error(`Failed to wait for workflow run: ${e.message}`);
} Prevention
- Verify the run ID exists (`archon workflow get`) before waiting.
- Keep database connectivity stable across long waits; prefer local SQLite for long polls.
- In automation, always use `--json` and branch on the `{ok:false}` line.
- Treat repeated wait failures as a storage-layer problem, not a workflow failure.
When it happens
Trigger: Waiting on a run when the wait API throws: database connection lost mid-poll, storage adapter error, or a corrupt run record preventing status resolution (distinct from the handled `not_found` result kind).
Common situations: Long waits spanning a network DB outage; SQLite lock contention while the run writes; run record corrupted by a crashed writer; repeated transient DB errors until the wait gives up.
Related errors
- --resume and --config are mutually exclusive. A resumed run
- Failed to download web UI: ${tarballRes.status} ${tarballRes
- Failed to read version: package.json is malformed
- Failed to start detached workflow child (executable: ${cmd[0
- Cannot create worktree: database lookup failed. Error: ${res
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/ec1e69bb3080749e.
Report an issue: GitHub.