跳到主要内容

SubFlow

查看 Markdown

This 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​

TaskTypeScript APIDex behavior
Start a child Flow and wait for itSubFlow.run in waitForSubFlows
Set the child timeout, Attributes, and configurationSubFlowOptionsSubFlowOptions
Choose what happens to an existing childreusePolicy of SubFlowOptions, with SubFlowReusePolicySubFlowReusePolicy
Read the child resultSubFlow.getConditionResults in execute. It returns a FlowResult.SubFlow results
Read the generated child Flow IDSubFlow.getFlowIdSubFlowReusePolicy
Stop a child that lost an AnyOfClient.stopFlow with the child Flow IDStop 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