cloudflare-workflows-for-long-tasks

Migrate Cloudflare Worker background tasks from ctx.waitUntil() to durable workflows.

Updated Apr 22, 2026
One-click install
npx skills add https://github.com/okayus/okayus-skills --skill cloudflare-workflows-for-long-tasks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cloudflare-workflows-for-long-tasks
Source: https://github.com/okayus/okayus-skills/tree/main/skills/cloudflare-workflows-for-long-tasks
Command: npx skills add https://github.com/okayus/okayus-skills --skill cloudflare-workflows-for-long-tasks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps migrate long-running Cloudflare Worker background tasks away from ctx.waitUntil() failures by replacing unreliable post-response execution with durable Cloudflare Workflows that survive beyond the 30-second limit.

Core Features & Use Cases

  • Workflow Migration Guidance: Converts waitUntil-based jobs into WorkflowEntrypoint implementations with durable steps, retries, and persisted execution state.
  • Production Reliability Patterns: Provides patterns for idempotent step design, serializable outputs, retry configuration, failure handling, and cleanup of orphaned database records.
  • Use Case: A Cloudflare Worker processing Vision LLM analysis, large files, or slow third-party API calls can use this Skill to migrate the job into a workflow with observable progress and automatic recovery.

Quick Start

Use the cloudflare-workflows-for-long-tasks skill to migrate my Worker background task from ctx.waitUntil() to a durable Cloudflare Workflow.

Frequently Asked Questions about cloudflare-workflows-for-long-tasks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Cloudflare Worker background task fail after the response is sent?

Background tasks using ctx.waitUntil() fail because they are not durable and cannot survive past the Worker execution limit. Migrating to Cloudflare Workflows replaces this unreliable post-response execution with durable steps that persist and recover automatically.

How do I migrate a long-running task from ctx.waitUntil() to Cloudflare Workflows?

To migrate a long-running task to Cloudflare Workflows, you convert the job into a WorkflowEntrypoint implementation using durable steps. This involves configuring step retries, ensuring serializable state handling, and applying idempotent persistence for reliable execution.

Can I use Cloudflare Workflows for slow API calls and AI inference in Workers?

Yes, Cloudflare Workflows support slow API calls, AI inference, file processing, and multi-step orchestration. They provide observable progress and automatic recovery for these long-running scenarios without hitting the 30-second execution limit.

What is the best way to handle state and retries in a Cloudflare Workflow?

The best way to handle state and retries in a Cloudflare Workflow is by using WorkflowEntrypoint patterns. This requires designing idempotent steps, managing serializable outputs, and configuring specific retry and failure handling logic for production reliability.

What are the limitations of using ctx.waitUntil() for multi-step orchestration?

The limitation of using ctx.waitUntil() for multi-step orchestration is its lack of durability, causing tasks to fail if they exceed the 30-second limit. It does not support observable progress, automatic recovery, or persisted execution state for complex jobs.

Do I need to clean up orphaned database records when migrating to Cloudflare Workflows?

Yes, migrating to Cloudflare Workflows requires production migration cleanup procedures to remove orphaned database records. This ensures that idempotent persistence and durable execution state remain consistent after replacing waitUntil jobs.