[Docs] Cookbook update for child workflows pattern#2100
Conversation
TooTallNate
left a comment
There was a problem hiding this comment.
Approve — all four asks addressed cleanly
Karthik's fix commit (1c0e18ff0 Fix child-workflows cookbook review feedback) addresses all four items from the previous review:
| Ask | Fix |
|---|---|
1. Type error in resumeParentCompletion (Docs Code Samples CI) |
Tightened to discriminated union in both v4 and v5 |
2. Missing zod dep (Vitest Plugin Tests CI) |
Added "zod": "catalog:" to workbench/vitest/package.json + lockfile |
3. Unused resumeHook import |
Removed |
| 4. No changeset | Added empty changeset .changeset/cookbook-child-workflows-hook-resume.md |
What I verified locally
pnpm install --frozen-lockfile✓ (lockfile updated cleanly)pnpm turbo run build --filter '!./workbench/*'✓pnpm --filter @workflow/docs-typecheck test:docs✓ (911/911 tests pass — child-workflows v4 and v5 both clean)cd workbench/vitest && pnpm test✓ (34/34 tests pass, includingshould spawn a child workflow via start() and collect its result)
CI
- 37 success, 0 failures, 73 in progress — both previously-failing checks now green:
- Docs Code Samples: pass (was failing on lines 33 of both v4 and v5)
- Vitest Plugin Tests: pass (was failing on zod resolution)
Branch hygiene
The ~10 merge commits from main are still there — they'll be squashed away on merge so it's not a blocker, but a rebase would clean up the working history.
Nice work on the pattern. The hook resume + withChildCompletionHook + startAndWait shape is clean, and the prose explanation of why hooks beat polling (zero compute, immediate wake, typed payloads, no worker-pool pressure) is well-grounded with the Eager Processing link.
Approving.
…workflows-hook-completion
Remove redundant polling comparison copy, the getRun() alternative section, and v5-only start() tips to keep the cookbook focused on the hook pattern. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No backport to All meaningful changes target docs cookbook pages ( To override, re-run the Backport to stable workflow manually via |
Summary
defineHook+withChildCompletionHook+startAndWait) instead ofgetRun().statuspolling loopsfinallyWhy
Polling child status in a durable sleep loop works but is slower to wake, holds worker slots when combined with
returnValue, and requires extra result-collection steps. The hook resume pattern lets each child signal completion directly and keeps the parent suspended with zero compute until the child finishes.Test plan
pnpm --filter @workflow/docs-typecheck typecheckpnpm exec vitest run test/cookbook-common.test.ts -t "child-workflows"inworkbench/vitest(local plugin env issue unrelated to this diff)/cookbook/advanced/child-workflowsfor v4 and v5Made with Cursor