{"record":{"id":"9dbbe4bfff78ef9e","repo":"coleam00/Archon","slug":"failed-to-abandon-workflow-run-run-id-err-me","errorCode":null,"errorMessage":"Failed to abandon workflow run ${run.id}: ${err.message}","messagePattern":"Failed to abandon workflow run (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/operations/workflow-operations.ts","lineNumber":440,"sourceCode":"\ninterface AbandonAttemptResult extends AbandonWorkflowResult {\n  cancelledDescendants: number;\n}\n\nasync function cancelRunAndCleanup(\n  run: WorkflowRun,\n  cancelRun: CancelWorkflowRun\n): Promise<AbandonAttemptResult> {\n  let cancelled: boolean;\n  try {\n    ({ cancelled } = await cancelRun(run.id));\n  } catch (error) {\n    const err = error as Error;\n    getLog().error(\n      { err, errorType: err.constructor.name, runId: run.id },\n      'operations.workflow_abandon_failed'\n    );\n    throw new Error(`Failed to abandon workflow run ${run.id}: ${err.message}`);\n  }\n\n  // The same cancellation policy applies to descendants. This keeps `/reset`'s\n  // resumable-only ownership boundary intact through the complete run tree.\n  let cascadeFailures = 0;\n  let cancelledDescendants = 0;\n  if (cancelled) {\n    ({ cancelled: cancelledDescendants, failures: cascadeFailures } = await cascadeCancelChildren(\n      run.id,\n      cancelRun\n    ));\n  }\n  const blockedParentRunId = cancelled ? await findParentBlockedOn(run) : null;\n\n  // Reclaim only when our cancel won the CAS. A miss means another lifecycle\n  // owner now controls the run and its environment.\n  if (cancelled) await reclaimCancelledRunContainer(run);\n  return { run, cancelled, cancelledDescendants, cascadeFailures, blockedParentRunId };","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/operations/workflow-operations.ts#L422-L458","documentation":"cancelRunAndCleanup wraps the underlying cancellation of a run during abandon; if the cancel call throws for any reason, the error is logged (with type and runId under 'operations.workflow_abandon_failed') and rethrown as 'Failed to abandon workflow run <id>: <cause>'. This is a boundary translation that preserves the original message for diagnostics.","triggerScenarios":"workflowDb.cancelWorkflowRun (or the injected cancel function) throws while abandoning a run — e.g. database write failure, lock contention, or a concurrent modification of the run row.","commonSituations":"SQLite/Postgres connection loss or busy-lock during abandon; two operators abandoning the same run simultaneously; disk-full or migration mismatch preventing the status write.","solutions":["Read the underlying cause in err.message and the 'operations.workflow_abandon_failed' log entry to fix the root issue (DB connectivity, lock, disk).","Retry the abandon once the database issue is resolved — abandon is safe to re-attempt on a still-abandonable run.","Verify no concurrent process is mutating the same run (check run status before retrying).","If the DB is persistently failing, check database health/permissions before further operations."],"exampleFix":"// before\nawait abandonWorkflow(runId); // may throw raw DB error wrapped here\n// after\ntry {\n  await abandonWorkflow(runId);\n} catch (e) {\n  logger.error({ runId, cause: (e as Error).message });\n  // fix DB issue, then retry\n}","handlingStrategy":"try-catch","validationCode":"await db.ping(); // verify database reachability before bulk abandon operations","typeGuard":null,"tryCatchPattern":"try { await abandonWorkflow(runId); }\ncatch (e) {\n  const msg = (e as Error).message;\n  if (msg.startsWith('Failed to abandon workflow run')) {\n    logger.error({ runId, cause: msg }, 'abandon failed; inspect operations.workflow_abandon_failed log and retry after fixing DB');\n  } else throw e;\n}","preventionTips":["Monitor database health (connections, locks, disk) before bulk run management.","Avoid concurrent abandon of the same run from multiple operators/scripts.","Check the 'operations.workflow_abandon_failed' structured log for err type and runId."],"tags":["workflow","database","cancel","error-wrapping"],"backgroundTag":"run-abandon-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}