Skip to content
// EFFECT DAYS 2026

CloudflareWorkflowEngine

Runs durable workflows on the dedicated workflow Durable Object class.

On this path one workflow execution is one Durable Object: the engine encodes (workflowName, executionId) into a Durable Object name with the same length-prefix scheme as entities and resolves the object through the workflow namespace binding. Execution state, activity results keyed ${name}/${attempt}, durable deferred exits, and the clock due table all live on the object's SQLite storage behind its single alarm.

Every DurableClock is durable on this engine: the in-memory short-sleep path is disabled, so even sub-minute sleeps persist a due row and arm the alarm.

3 exports Since v4.1.3 Source

Constructors

Since v4.1.3

Creates the WorkflowEngine service backed by the workflow Durable Object namespace binding.

Details

Inside a workflow Durable Object the engine operates on the local execution handle, so activities and deferred reads never leave the object. Everywhere else it resolves the target execution's object with getByName and drives it over the same-Worker binding.

Signature

declare const make: (...args: [options: LayerOptions]) => Effect<{
readonly activityExecute: <Success extends Constraint, Error extends Constraint, R>(activity: Activity<Success, Error, R>, attempt: number) => Effect<Result<Success["Type"], Error["Type"]>, never, WorkflowInstance | R | Success["DecodingServices"] | Error["DecodingServices"]>;
readonly deferredDone: <Success extends Constraint, Error extends Constraint>(deferred: DurableDeferred<Success, Error>, options: {
readonly deferredName: string;
readonly executionId: string;
readonly exit: Exit<Success["Type"], Error["Type"]>;
readonly workflowName: string;
}) => Effect<void, never, Success["EncodingServices"] | Error["EncodingServices"]>;
readonly deferredResult: <Success extends Constraint, Error extends Constraint>(deferred: DurableDeferred<Success, Error>) => Effect<Option<Exit<Success["Type"], Error["Type"]>>, never, WorkflowInstance>;
readonly execute: <Name extends string, Payload extends AnyStructSchema, Success extends Top, Error extends Top, Discard extends boolean = false>(workflow: Workflow<Name, Payload, Success, Error>, options: {
readonly detached?: boolean;
readonly discard?: Discard;
readonly executionId: string;
readonly payload: Payload["Type"];
readonly suspendedRetrySchedule?: Schedule<any, unknown, never, never>;
}) => Effect<Discard extends true ? string : Success["Type"], Error["Type"], Payload["EncodingServices"] | Success["DecodingServices"] | Error["DecodingServices"]>;
readonly interrupt: (workflow: Any, executionId: string) => Effect<void>;
readonly interruptUnsafe: (workflow: Any, executionId: string) => Effect<void>;
readonly poll: <Name extends string, Payload extends AnyStructSchema, Success extends Top, Error extends Top>(workflow: Workflow<Name, Payload, Success, Error>, executionId: string) => Effect<Option<Result<Success["Type"], Error["Type"]>>, never, Success["DecodingServices"] | Error["DecodingServices"]>;
readonly register: <Name extends string, Payload extends AnyStructSchema, Success extends Top, Error extends Top, R>(workflow: Workflow<Name, Payload, Success, Error>, execute: (payload: Payload["Type"], executionId: string) => Effect<Success["Type"], Error["Type"], R>) => Effect<void, never, Scope | Exclude<R, WorkflowEngine | Scope | WorkflowInstance | Execution<Name>> | Payload["DecodingServices"] | Payload["EncodingServices"] | Success["DecodingServices"] | Success["EncodingServices"] | Error["DecodingServices"] | Error["EncodingServices"]>;
readonly resume: (workflow: Any, executionId: string) => Effect<void>;
readonly scheduleClock: (workflow: Any, options: {
readonly clock: DurableClock;
readonly executionId: string;
}) => Effect<void>;
}, never, never>

Layers

Since v4.1.3

Layer that provides the WorkflowEngine backed by the workflow Durable Object namespace binding.

Details

CloudflareCluster.layer already includes this layer; use it directly only when the workflow engine is needed without the rest of the cluster.

Signature

declare function layer(options: LayerOptions): Layer<WorkflowEngine>

LayerOptions

interface
Since v4.1.3

The workflow Durable Object namespace binding the engine is built from.

Signature

interface LayerOptions {
readonly workflowNamespace: DurableObjectNamespace;
}