GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • celld
  • Docs
  • GitHub
  • Releases

This view

  • Original page
  • New address

GeezerVison is showing celld.dev — Workflows · celld

OverviewCloudflare compatibilityLimitationsSecurityTelemetryTestingWebAssemblyWhat celld guarantees

Services

ContainersCron TriggersD1Durable Object FacetsDurable Objects / CellsDynamic WorkersKVQueuesR2Static assetsWorkersWorkflows
On this page

Documentation

Workflows

A Workflow is a durable function that runs as a named sequence of steps, sleeps, and events. celld runs each instance as a cell. Read the Cloudflare Workflows documentation for the API.

Example

The Workflow example fetches a document and stores the result of a durable step.

index.js
import { WorkflowEntrypoint } from "cloudflare:workers";

export class ReportBuilder extends WorkflowEntrypoint {
  async run(event, step) {
    // A completed step returns its stored result when the Workflow resumes.
    return await step.do("build report", async () => {
      const response = await fetch(event.payload.url);
      if (!response.ok) throw new Error(`source answered ${response.status}`);
      const text = await response.text();
      return { bytes: text.length, lines: text.split("\n").length };
    });
  }
}

export default {
  async fetch(request, env) {
    const url = new URL(request.url);
    const id = url.searchParams.get("id");

    if (url.pathname === "/create") {
      const instance = await env.REPORTS.create({
        params: { url: url.searchParams.get("url") ?? "https://example.com" },
      });
      return Response.json({ id: instance.id });
    }

    if (url.pathname === "/status" && id) {
      const instance = await env.REPORTS.get(id);
      return Response.json(await instance.status());
    }

    return new Response("Use /create?url=URL or /status?id=ID.", {
      status: 404,
    });
  },
};
wrangler.jsonc
{
  "name": "workflow",
  "main": "index.js",
  "compatibility_date": "2026-08-18",
  "workflows": [
    {
      "binding": "REPORTS",
      "name": "report-builder",
      "class_name": "ReportBuilder"
    }
  ]
}

API

  • A class extends WorkflowEntrypoint and implements run(event, step). event.payload holds the parameters, and the return value becomes the output field of status().
  • step.do(name, callback) runs a durable step, and it retries the callback on failure.
  • step.sleep(name, duration) and step.sleepUntil(name, timestamp) stop the instance until a deadline.
  • step.waitForEvent(name, options) stops the instance until a matching event.
  • env.MY_WORKFLOW.create(), createBatch(), and get(id) return an instance. deleteBatch() deletes several instances.
  • An instance has status(), sendEvent(), pause(), resume(), restart(), terminate(), and delete().

Replay

Each time an instance makes progress, celld calls run() again from the first line. A finished step returns its stored result and does not run its callback again. All code outside a step callback therefore runs again on every replay. Put each subrequest, each side effect, and each value that must stay stable inside a step.do() callback, as the rules of Workflows require. A step whose result did not commit before a node failure runs again, so a step callback must tolerate a second attempt.

run() can await work that is not a step, but a replay cannot resume that await. celld fails the instance when such work keeps run() pending for 60 seconds while no step runs or waits.

Sleeps, events, and retries

step.waitForEvent() times out after 24 hours by default. An event that arrives before the instance reaches its wait step is buffered. A sleep, a wait, and a pending retry each store their deadline, so a crash or a slow replay cannot move the deadline. status() reports waiting for all three.

A waiting instance holds no isolate. Its cell hibernates when the next deadline is further away than the near-alarm residency window. That window is one hour, and CELLD_ALARM_RESIDENT_MS changes it.

step.do() uses the Cloudflare retry defaults when the call supplies no retries object: 5 retries, a delay of 10 seconds, exponential backoff, and a timeout of 10 minutes for one attempt.

celld sets no limit on the number of concurrent instances. Fleet memory and the resident-cell cap bound it.

Differences from Cloudflare

  • celld retains a successful or failed instance for 30 days by default. Each duration in the retention option can be at most 30 days.
  • locationHint accepts the Cloudflare values, but fleet ownership selects the cell location.
  • Non-step work cannot remain pending for more than 60 seconds.
  • A step result, an event payload, and the workflow parameters each have a 1 MiB limit.
  • Rollback, a sensitive step result, and a ReadableStream step result are unavailable.
  • A workflows entry cannot carry schedules, limits, or a script_name that names another script.
  • The Workflows REST API and the wrangler workflows commands are unavailable. Drive an instance through the binding.

The Cloudflare compatibility page lists the runtime APIs and the unsupported services.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.