{"record":{"id":"5c3c83ffdf1e71c3","repo":"coleam00/Archon","slug":"failed-to-list-due-workflow-continuations-err-m","errorCode":null,"errorMessage":"Failed to list due workflow continuations: ${err.message}","messagePattern":"Failed to list due workflow continuations: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/db/workflows.ts","lineNumber":1566,"sourceCode":"  const retryAt =\n    getDatabaseType() === 'postgresql'\n      ? \"metadata->>'continuation_retry_at'\"\n      : \"json_extract(metadata, '$.continuation_retry_at')\";\n  try {\n    const result = await pool.query<WorkflowRun>(\n      `SELECT * FROM remote_agent_workflow_runs\n       WHERE (${retryAt} IS NULL OR ${retryAt} <= $1)\n         AND ((status = 'paused' AND (${signaledAt} IS NOT NULL OR ${resumeAt} <= $1))\n          OR (status = 'failed' AND ${scheduledResumeAt} <= $1 AND ${scheduledTriggeredAt} IS NULL))\n       ORDER BY COALESCE(${retryAt}, ${resumeAt}, ${scheduledResumeAt}) ASC\n       LIMIT $2`,\n      [now.toISOString(), limit]\n    );\n    return result.rows.map(normalizeWorkflowRun);\n  } catch (error) {\n    const err = error as Error;\n    getLog().error({ err }, 'db.workflow_continuation_due_list_failed');\n    throw new Error(`Failed to list due workflow continuations: ${err.message}`);\n  }\n}\n\n/** Back off a continuation that could not acquire execution prerequisites. */\nexport type WorkflowContinuationCursor = WorkflowResumeCursor;\n\nexport async function deferWorkflowContinuation(\n  id: string,\n  retryAt: string,\n  cursor: WorkflowContinuationCursor\n): Promise<void> {\n  const dialect = getDialect();\n  const waitResumeAt =\n    getDatabaseType() === 'postgresql'\n      ? \"metadata->'wait'->>'resumeAt'\"\n      : \"json_extract(metadata, '$.wait.resumeAt')\";\n  const scheduledResumeAt =\n    getDatabaseType() === 'postgresql'","sourceCodeStart":1548,"sourceCodeEnd":1584,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/db/workflows.ts#L1548-L1584","documentation":"Thrown by listDueWorkflowContinuations when the SELECT for time/deadline waits eligible for a resume claim fails. The query mixes dialect-specific JSON expressions (metadata->'wait' for Postgres, json_extract for SQLite) on `remote_agent_workflow_runs`; any driver/SQL failure is logged as `db.workflow_continuation_due_list_failed` and rethrown with this message. An empty result is not an error — only an actual query failure throws.","triggerScenarios":"Calling listDueWorkflowContinuations(now, limit) when the database is unreachable, the parameter types are rejected (e.g. now not serializing to ISO), or a dialect JSON-path expression is invalid for the configured engine.","commonSituations":"Database down or pool exhausted while the continuation poller runs; switching database types without migrating so JSON expressions no longer match; corrupted JSON in a metadata column making extraction fail on some engines.","solutions":["Read the paired `db.workflow_continuation_due_list_failed` log for the driver-level cause","Verify DB connectivity and pool health, then let the poller retry","Confirm getDatabaseType() matches the deployed schema (Postgres vs SQLite JSON syntax)","Validate metadata JSON integrity if extraction errors appear"],"exampleFix":"// before\nconst due = await listDueWorkflowContinuations(new Date(), 10); // throws on DB blip\n// after\nlet due = [];\ntry {\n  due = await listDueWorkflowContinuations(new Date(), 10);\n} catch (e) {\n  logger.warn({ err: e }, 'continuation scan skipped this tick');\n}","handlingStrategy":"retry","validationCode":"// cheap pre-flight: is the DB reachable?\nawait getDatabase().query('SELECT 1');","typeGuard":"function isDueContinuationCandidate(run: WorkflowRun): boolean {\n  return run.status === 'paused' || run.status === 'failed';\n}","tryCatchPattern":"const due = await withRetry(\n  () => listDueWorkflowContinuations(now, limit),\n  { retries: 3, backoffMs: 500, onRetry: (e, n) => log.warn({ e, n }, 'retrying continuation scan') }\n);","preventionTips":["Run the continuation poller with tolerant retry/backoff around DB blips","Keep run metadata JSON valid; validate before persisting","Test after switching SQLite/Postgres so dialect expressions are exercised","Alert on repeated `db.workflow_continuation_due_list_failed` events"],"tags":["database","workflow","polling"],"backgroundTag":"database-query-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}