{"record":{"id":"c79a407eadc942f6","repo":"coleam00/Archon","slug":"failed-to-recover-cancelled-fan-out-run-err-mes","errorCode":null,"errorMessage":"Failed to recover cancelled fan-out run: ${err.message}","messagePattern":"Failed to recover cancelled fan-out run: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/db/workflows.ts","lineNumber":1089,"sourceCode":"        `DELETE FROM remote_agent_workflow_events\n         WHERE workflow_run_id = $1\n           AND event_type = 'workflow_cancelled'\n           AND ${eventReason} IN ($2, $3, $4)`,\n        [id, ...FAN_OUT_CANCEL_REASONS]\n      );\n      const recovered = await query<WorkflowRun>(\n        'SELECT * FROM remote_agent_workflow_runs WHERE id = $1',\n        [id]\n      );\n      const row = recovered.rows[0];\n      if (!row) throw new Error(`Workflow run not found after fan-out recovery (id: ${id})`);\n      return normalizeWorkflowRun(row);\n    });\n  } catch (error) {\n    if (error instanceof Error && error.message.startsWith('Workflow run ')) throw error;\n    const err = error as Error;\n    getLog().error({ err, workflowRunId: id }, 'db.workflow_run_fan_out_recover_failed');\n    throw new Error(`Failed to recover cancelled fan-out run: ${err.message}`);\n  }\n}\n\n/**\n * Find the most recent workflow run for a worker platform conversation ID.\n * Joins with conversations table to resolve platform_conversation_id → DB id.\n */\nexport async function getWorkflowRunByWorkerPlatformId(\n  platformConversationId: string\n): Promise<WorkflowRun | null> {\n  try {\n    const result = await pool.query<WorkflowRun>(\n      `SELECT r.* FROM remote_agent_workflow_runs r\n       JOIN remote_agent_conversations c ON r.conversation_id = c.id\n       WHERE c.platform_conversation_id = $1\n       ORDER BY r.started_at DESC LIMIT 1`,\n      [platformConversationId]\n    );","sourceCodeStart":1071,"sourceCodeEnd":1107,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/db/workflows.ts#L1071-L1107","documentation":"Error \"Failed to recover cancelled fan-out run: ${err.message}\" thrown in coleam00/Archon.","triggerScenarios":"Thrown at packages/core/src/db/workflows.ts:1089 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}