You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/child-workflows.md
+75Lines changed: 75 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,6 +141,81 @@ When the parent is blocked on a child, Waterline shows it as a child wait rather
141
141
- if that parent resume workflow task row is lost after the child-resolution event, selected-run detail stays `repair_needed`, exposes a synthetic missing workflow task with `workflow_wait_kind = child`, `child_call_id`, and `child_workflow_run_id`, and manual `repair()`, `workflow:v2:repair-pass`, or worker-loop repair recreates the same child-resolution task from typed parent history
142
142
- lineage arrays expose the durable parent/child relationship alongside continue-as-new links, and child-workflow entries now carry the same `child_call_id`
143
143
144
+
## Parent-Close Policy
145
+
146
+
When a parent workflow closes — whether by completing, failing, timing out, being cancelled, or being terminated — each open child workflow is affected according to its **parent-close policy**. The policy is set per child call and controls what happens to that child when the parent run exits.
147
+
148
+
| Policy | Value | Behavior |
149
+
|---|---|---|
150
+
| Abandon |`abandon`| The child continues running independently. This is the default. |
151
+
| Request Cancel |`request_cancel`| A cancel command is sent to the child when the parent closes. |
152
+
| Terminate |`terminate`| A terminate command is sent to the child when the parent closes. |
153
+
154
+
### Setting the policy
155
+
156
+
Pass a `ChildWorkflowOptions` as the first argument to `child()` or `startChild()`:
- The policy is recorded on the `workflow_links` row (`parent_close_policy`) and in the `ChildWorkflowScheduled` history event payload.
198
+
- When the parent run closes for any reason, the engine queries open child links with a non-abandon policy and sends the appropriate command (cancel or terminate) to each open child.
199
+
- If the child has already closed by the time the policy is enforced, no action is taken — the command is silently skipped.
200
+
- Policy enforcement is best-effort: if a child command is rejected (e.g. the child is already terminal), the parent's closure is not affected.
201
+
- Continue-as-new does **not** trigger parent-close policy, because the workflow instance remains active under a new run.
202
+
203
+
### When to use each policy
204
+
205
+
**Abandon** (default) is correct when children represent independent work that should complete regardless of the parent's fate — for example, a notification workflow or a cleanup task that must finish.
206
+
207
+
**Request Cancel** is correct when children should receive a graceful shutdown signal. The child can handle the cancellation and run compensation logic before closing.
208
+
209
+
**Terminate** is correct when children must stop immediately. Use this for children that are purely auxiliary to the parent and have no independent value after the parent closes.
210
+
211
+
### Waterline visibility
212
+
213
+
Waterline shows the `parent_close_policy` in:
214
+
215
+
- the child link entry on the parent run's lineage view
216
+
- the `ChildWorkflowScheduled` timeline entry payload
217
+
- the child's `CancelRequested` or `TerminateRequested` history event when policy enforcement fires, with a reason that names the parent closure
0 commit comments