Cloudflare Durable Workflows

Published
Length
3 min read

Luis Felipe Dias

All posts

You build cloudflare durable workflows by chaining discrete steps that save state to edge storage. Each step retries on failure and resumes from the last saved point without repeating finished work. Teams often set up these background jobs with broad account keys to reach internal databases. When those keys have wide permissions, one bad step can change or delete critical production rows. How cloudflare durable workflows run and store state Standard serverless functions time out when an exter

Access Request Workflows: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You build cloudflare durable workflows by chaining discrete steps that save state to edge storage. Each step retries on failure and resumes from the last saved point without repeating finished work. Teams often set up these background jobs with broad account keys to reach internal databases. When those keys have wide permissions, one bad step can change or delete critical production rows.

How cloudflare durable workflows run and store state

Standard serverless functions time out when an external API takes too long to respond. If a network blip happens halfway through a job, the whole script fails and loses context. A durable workflow fixes this by breaking a long task into smaller, separate steps.

The platform runs each step in order and writes the output to persistent storage right away. If step three fails, the engine waits based on your retry rule and runs step three again. Steps one and two do not run a second time because their results are already saved.

To make this work, developers bind the workflow engine to a worker script in their account. The worker receives an event, starts a new workflow instance, and tracks its unique run ID. A job can pause for hours or days while it waits for an external webhook signal. When the signal arrives, the instance wakes up, reads its saved state, and runs the next step.

Securing secrets and data in multi-step edge jobs

Long jobs rarely stay inside one edge network. A typical run pulls user records from Postgres, calls a payment API, and updates a dashboard. To do these tasks, the worker needs secrets like database passwords and API keys. Teams bind these secrets to the worker so every step can read them during a run.

Storing secrets in the worker platform keeps them out of source control. Still, this setup still gives the entire workflow full permissions for every linked database and service. If a step runs a bad SQL query, the database accepts it because the key is valid. If a query pulls customer emails or card numbers, those raw values sit in the saved state.

Anyone on the team who can read workflow logs might see those sensitive fields in plain text. Masking rules that rewrite emails and card numbers in query results prevent raw data from entering storage. Teams also need a way to check individual commands in flight before they reach the database.

Access Request Workflows: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Where native account roles leave an operational gap

Platform role settings control which engineers can deploy workers or view workflow status in the dashboard. Secret bindings control which workers can log in to your external databases and internal APIs. These native controls solve the basic problem of who can deploy code and start a run.

They do not inspect what individual SQL statements or API requests do once the run starts. A shared database user lets a background step run a drop table command just like a select query. Native worker logs also record step status rather than full audit trails of every external database query.

During an incident, an engineer often needs to run a manual fix against the same production database. Giving that engineer the raw database password creates risk and leaves no clear record of their commands. Teams need command-level rules, data masking in results, and approval checks for sensitive actions across their systems.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

What happens when a single step fails in a durable workflow?

The engine pauses that specific step and retries it based on your backoff rules. Earlier steps do not run again because the platform reads their saved outputs from storage.

Why should teams avoid putting raw PII into workflow state?

Workflow state persists on disk between steps so the job can resume after pauses or crashes. If raw card numbers or phone numbers enter that state, they stay stored in logs and step payloads.

Can platform roles restrict which SQL queries a workflow step runs?

No, platform roles only govern who can manage the worker script and its secret bindings. Once the worker logs in to a database, the database role decides which queries can run.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.