coleam00/Archon · error

Failed to cancel resumable runs for conversation: ${err.mess

Error message

Failed to cancel resumable runs for conversation: ${err.message}

What it means

cancelResumableRunsForConversation runs its SELECT, UPDATE, and event inserts inside a transaction; if anything in that transaction throws — including a DB-level error, not the snapshot mismatch in [242] — it is logged (db.workflow_run_cancel_resumable_for_conv_failed) and rethrown with this message. The transaction is rolled back, so no partial cancellations persist.

Source

Thrown at packages/core/src/db/workflows.ts:633

        [conversationId, conversationId]
      );
      if (result.rowCount !== resumable.length) {
        throw new Error(
          `Resumable run snapshot changed during reset (expected ${String(resumable.length)}, cancelled ${String(result.rowCount)})`
        );
      }
      for (const run of resumable) {
        await insertWorkflowEvent(query, {
          workflow_run_id: run.id,
          event_type: 'workflow_cancelled',
        });
      }
      return resumable.map(run => normalizeWorkflowRun(run));
    });
  } catch (error) {
    const err = error as Error;
    getLog().error({ err, conversationId }, 'db.workflow_run_cancel_resumable_for_conv_failed');
    throw new Error(`Failed to cancel resumable runs for conversation: ${err.message}`);
  }
}

/**
 * Find the workflow run currently holding the lock on `workingPath`.
 *
 * The lock is held by any row in `(running, paused)` or `pending` younger
 * than `STALE_PENDING_AGE_MS` (orphaned pre-creates beyond that window are
 * ignored — they're from crashed or resume-replaced dispatches).
 *
 * When called from a dispatch that already pre-created its own row, pass
 * `self` (`id` + `startedAt`) so:
 *   1. Self is never returned.
 *   2. If two dispatches both have rows, the deterministic older-wins
 *      tiebreaker `(started_at, id)` ensures both agree on which is "first."
 *      The newer dispatch sees the older row and aborts; the older dispatch
 *      sees nothing.
 *

View on GitHub (pinned to 0773b97458)

Solutions

  1. Inspect the wrapped err.message and the db.workflow_run_cancel_resumable_for_conv_failed log for the real cause.
  2. Retry the operation after transient errors (deadlock, connection reset); the rollback makes it safe.
  3. Check for competing transactions locking the same run rows and serialize the reset.
  4. Verify INSERT permissions on workflow_events and UPDATE permissions on workflow_runs.

Example fix

// before
await cancelResumableRunsForConversation(conversationId);
// after
try {
  await cancelResumableRunsForConversation(conversationId);
} catch (err) {
  getLog().error({ err, conversationId }, 'conversation.reset_cancel_failed');
  throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

const ping = await pool.query('SELECT 1'); // fail fast if DB is unreachable before opening the transaction

Type guard

function isCancelResumableError(err: unknown): err is Error {
  return err instanceof Error && err.message.startsWith('Failed to cancel resumable runs for conversation:');
}

Try / catch

try {
  await cancelResumableRunsForConversation(conversationId);
} catch (err) {
  // Transaction rolled back — no partial cancellation. Inspect err.message for deadlock/constraint cause.
  getLog().error({ err, conversationId }, 'conversation_reset_failed');
  throw err;
}

Prevention

When it happens

Trigger: Calling cancelResumableRunsForConversation when the DB connection drops mid-transaction, an INSERT into workflow_events violates a constraint, a deadlock occurs with another writer, or permissions prevent the UPDATE on workflow_runs.

Common situations: Connection pool closed during shutdown; another transaction holding row locks on the same workflow_runs rows (deadlock); workflow_events schema drift; disk-full on the DB server aborting writes.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01). Data as JSON: /api/errors/454ea5ee5db24808. Report an issue: GitHub.