Skip to content

fix(workflow): wake all parents awaiting a shared child execution - #10885

Open
effect-bot wants to merge 10 commits into
mainfrom
agent/effect-bot/45c0bea6ab54
Open

effect-bot wants to merge 10 commits into
mainfrom
agent/effect-bot/45c0bea6ab54

Conversation

@effect-bot

Copy link
Copy Markdown
Contributor

Summary

Wake every non-detached parent awaiting a shared child workflow execution across ClusterWorkflowEngine, WorkflowEngine.layerMemory, and CloudflareWorkflowEngine.

Previously, when multiple parent workflows executed the same child idempotency key (or joined a child started standalone), only one parent was recorded and woken when the child completed, leaving other waiting parents Suspended.

Changes

  • Cluster (packages/effect/src/cluster/ClusterWorkflowEngine.ts):
    • Added a persisted parent RPC keyed by consecutive index (String(index)) on workflow entities.
    • Non-detached child executions register the parent before sending run, stopping at the first slot returning the same parent (with primary-key deduplication acting as compare-and-set).
    • On completion (including interruption), registeredParents scans consecutive slots (reading unprocessed messages as well as replies), merges the run payload parent for backward compatibility, deduplicates, and wakes each parent via sendResumeParent.
    • Mixed-version runners: if an older runner rejects the unknown parent RPC with a defect, Effect.catchDefect stops probing immediately and falls back to the parent carried on the run payload; replays reuse slot 0's cached defect reply instead of probing further indexes. New runners still read the run payload parent so old-runner parents are woken alongside newly registered parents.
  • Cloudflare (packages/platform/cloudflare/src/internal/workflowStorage.ts, workflowRuntime.ts):
    • Added a workflow_parents (workflow_name, execution_id) table and insert non-detached parents synchronously in run while the execution is incomplete.
    • deliverParentWake wakes every remaining parent concurrently and deletes each row only once its resume is acknowledged. Unreachable parents stay in workflow_parents for the guard alarm retry without blocking other parents or re-waking parents whose rows were already deleted. resume_pending now tracks only pending replays.
    • Migrates legacy parent_name/parent_execution_id columns on construction: copies into workflow_parents when incomplete or when resume_pending was set on a completed execution, then nulls the legacy columns (and clears resume_pending if already complete).
  • Memory (packages/effect/src/workflow/WorkflowEngine.ts):
    • Replaced single parent with a Set<string> of parents, adding every non-detached caller (including joins on existing executions) and waking all entries on Complete.
  • Tests & Changesets:
    • Added regression tests across all three engines plus tests for mixed-version Cluster fallback, Cloudflare per-parent wake retry without re-waking succeeded parents, and SQLite legacy parent migration.
    • Added patch changesets for effect and @effect/platform-cloudflare.

Closes #10862
Closes EFF-4221

Co-authored-by: RhysSullivan [email protected]

@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: baea3c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
effect Patch
@effect/platform-cloudflare Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-janitor effect-janitor Bot added the 4.0 label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.17 KB 40.17 KB 0.00 KB (0.00%)
basic.ts 7.31 KB 7.31 KB 0.00 KB (0.00%)
batching.ts 11.29 KB 11.29 KB 0.00 KB (0.00%)
brand.ts 7.05 KB 7.05 KB 0.00 KB (0.00%)
cache.ts 11.75 KB 11.75 KB 0.00 KB (0.00%)
config.ts 23.18 KB 23.18 KB 0.00 KB (0.00%)
differ.ts 22.30 KB 22.30 KB 0.00 KB (0.00%)
http-client.ts 27.87 KB 27.87 KB 0.00 KB (0.00%)
http-router.ts 38.66 KB 38.66 KB 0.00 KB (0.00%)
logger.ts 12.19 KB 12.19 KB 0.00 KB (0.00%)
metric.ts 9.66 KB 9.66 KB 0.00 KB (0.00%)
optic.ts 7.28 KB 7.28 KB 0.00 KB (0.00%)
pubsub.ts 16.23 KB 16.23 KB 0.00 KB (0.00%)
queue.ts 13.13 KB 13.13 KB 0.00 KB (0.00%)
schedule.ts 11.99 KB 11.99 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.36 KB 14.36 KB 0.00 KB (0.00%)
schema-binary.ts 42.92 KB 42.92 KB 0.00 KB (0.00%)
schema-class.ts 22.01 KB 22.01 KB 0.00 KB (0.00%)
schema-codegen.ts 30.78 KB 30.78 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.64 KB 30.64 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.33 KB 28.33 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.61 KB 15.61 KB 0.00 KB (0.00%)
schema-string.ts 12.56 KB 12.56 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.50 KB 16.50 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.72 KB 39.72 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.20 KB 21.20 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.36 KB 21.36 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.45 KB 21.45 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.50 KB 26.50 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.54 KB 21.54 KB 0.00 KB (0.00%)
schema.ts 21.14 KB 21.14 KB 0.00 KB (0.00%)
stm.ts 14.48 KB 14.48 KB 0.00 KB (0.00%)
stream.ts 10.61 KB 10.61 KB 0.00 KB (0.00%)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workflow: a child execution wakes only one parent; another parent awaiting the same child stays Suspended

1 participant