Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eersnington/sideffect/llms.txt
Use this file to discover all available pages before exploring further.
WorkflowEngine is the low-level runtime bridge that connects Sideffect workflow layers to the Cloudflare Workers runtime. Most users will never call it directly — it is used internally by WorkflowEntrypoints.make() and by the Vite-generated virtual:sideffect/entry module. Import it from sideffect.
You might reach for WorkflowEngine directly when:
- Writing a custom
WorkflowEntrypointsubclass that needs to delegate to a Sideffect layer without going throughWorkflowEntrypoints.make(). - Writing unit or integration tests that exercise workflow execution without a full Vite setup.
- Building a plugin or adapter that needs explicit control over
NonRetryableErrorconversion.
WorkflowEngine.make()
Creates a named WorkflowEntrypoint subclass constructor that wraps a single Sideffect layer.
This is the lower-level primitive that WorkflowEntrypoints.make() calls for each entry.
Function signature
Parameters
The export name and class name for the generated entrypoint class. Must be a valid JavaScript
identifier — the same constraint imposed by
WorkflowEntrypoints.make(). Cloudflare’s runtime
uses this name to match against the class_name in your Wrangler workflow binding config.The Sideffect workflow layer to bind to the generated entrypoint. Created by
Workflow.make(...).toLayer(...).The Cloudflare
WorkflowEntrypoint base class imported from cloudflare:workers. Sideffect
accepts this as a parameter instead of importing it directly so that the core sideffect package
does not take a hard dependency on cloudflare:workers (which is only available inside the
Cloudflare Workers runtime).The Cloudflare native
NonRetryableError constructor from cloudflare:workflows. When provided,
Sideffect converts its own portable NonRetryableError instances to the native Cloudflare
version at the workflow boundary. If omitted, portable NonRetryableError instances are still
treated as non-retryable by the Workers SDK based on error name matching, but native conversion
does not occur.Return value
A
WorkflowEntrypoint subclass whose run(event, step) method delegates to
WorkflowEngine.run(layer, { ... }). The class is named using a computed property key so that
constructor.name === exportName.Example
WorkflowEngine.run()
Executes a Sideffect workflow layer with a native Cloudflare workflow event and step API.
This is the method called by the generated run(event, step) inside every entrypoint class
produced by WorkflowEngine.make().
Function signature
Parameters
The Sideffect workflow layer to execute.
The Worker environment bindings object from the
WorkflowEntrypoint instance (this.env).
Passed through to the layer’s run function and to every step callback as context.env.The Worker execution context from the
WorkflowEntrypoint instance (this.ctx).
Passed through to the layer’s run function and to every step callback as context.ctx.The raw Cloudflare workflow event object before Sideffect decodes the payload. The
payload
field on the event is the untyped value as received from the Cloudflare runtime;
WorkflowEngine.run() decodes it using the layer’s payloadSchema before passing it to the
layer’s run function.The native Cloudflare
WorkflowStep API object passed to WorkflowEntrypoint.run() by the
Cloudflare runtime. Sideffect wraps it with a SideffectStep façade that adds typed payload and
result decoding for step.do() calls.Optional Cloudflare native
NonRetryableError constructor from cloudflare:workflows. When
provided, any Sideffect NonRetryableError thrown by the layer or its steps is converted to the
native version before propagating to the Cloudflare runtime.Return value
A promise that resolves with the return value of the layer’s
run function. The return type is
inferred from the layer’s WorkflowLayer<Payload, Result> type parameters.If the layer throws a Sideffect NonRetryableError and options.NonRetryableError was provided,
the promise rejects with the native Cloudflare NonRetryableError — causing the Cloudflare
runtime to mark the workflow as failed without retrying. Any other thrown error propagates
unchanged.Example
The following shows a customWorkflowEntrypoint that calls WorkflowEngine.run() directly,
giving you the option to inject custom logic before and after workflow execution: