SubFlow
View as MarkdownThis page lists the TypeScript SDK names for SubFlows. The doc comment of each API gives its parameters, defaults, and errors. Read them in the TypeScript SDK API reference.
API names
| Task | TypeScript API | Dex behavior |
|---|---|---|
| Start a child Flow and wait for it | SubFlow.run in waitFor | SubFlows |
| Set the child timeout, Attributes, and configuration | SubFlowOptions | SubFlowOptions |
| Choose what happens to an existing child | reusePolicy of SubFlowOptions, with SubFlowReusePolicy | SubFlowReusePolicy |
| Read the child result | SubFlow.getConditionResults in execute. It returns a FlowResult. | SubFlow results |
| Read the generated child Flow ID | SubFlow.getFlowId | SubFlowReusePolicy |
| Stop a child that lost an AnyOf | Client.stopFlow with the child Flow ID | Stop a Flow |
Step types that start SubFlows
Changed in 1.45: a Step whose Step type contains "-" cannot start SubFlows.
The generated child Flow ID joins the parent Flow ID, the Step execution ID, and the SubFlow index with "-". The Step execution ID itself is the Step type, "-", and a counter:
SubFlow:{parent Flow ID}-{Step execution ID}-{index}
{Step execution ID} = {Step type}-{n}
A dash in the Step type makes the child Flow ID ambiguous. In this example two parents would share one child:
parent Flow ID "a-b", Step type "C" -> SubFlow:a-b-C-1-0
parent Flow ID "a", Step type "b-C" -> SubFlow:a-b-C-1-0
When a waitFor whose Step type contains "-" returns a SubFlow.run condition, the server rejects the result as an invalid Worker response. It fails the attempt without retry, so under the default policy the Flow fails. The Worker logs a warning that names the Step type. A Step type with "-" that never starts SubFlows still works. To fix the error, rename the Step type that getStepType returns, for example from "b-C" to "bC".
Example
Example: examples/typescript/src/primitives/subflow/subflow-flow.ts