← Back to Home

How to Track and Cancel Active Cloudflare Workflow Runs

Updated March 5, 2026
cloudflare workflowsworkflow runscancellationd1operations

Active Workflow Tracking and Cancellation

Track runtime instances in D1 so frontend/API can list and cancel in-flight work.

Table-driven State

Use workflow_runs as source of truth for control-plane operations.

States:

Creation + Transition

await createWorkflowRun(db, { workflowId, stage, videoId, triggerSource, status: 'queued' });
await markWorkflowRunRunning(db, workflowId);

On finish/failure:

On manual cancellation:

API Pattern

Guardrail

Always read current run state before canceling to avoid canceling already terminal runs.