--- title: 'Merge' description: 'Waits for branches to converge before continuing.' --- # Merge Accepts N incoming edges and fires its single outgoing edge based on a wait policy. Use this to rejoin parallel branches or to wait until several conditions have fired. ## When to use - You fanned out with **Parallel Split** and now need to wait for all branches before continuing. - You have multiple upstream paths that each "might" run, and you want the workflow to continue as soon as at least one does. - Synchronizing multiple loop iterations before a final step. ## Configuration | Field | Required | What it does | |---|---|---| | `mode` | Yes | `wait_all` (default) or `first_wins`. | ### Modes - **Wait for All (`wait_all`)** — Merge fires its output only when *every* incoming edge has delivered. If any upstream branch terminates early (due to a filter or condition), Merge will wait forever. Make sure every incoming edge either delivers or the branch is structured so that the Merge's input from that branch isn't relied upon. - **First Wins (`first_wins`)** — Merge fires its output as soon as *any* incoming edge delivers. Remaining upstream branches continue running to completion but their arrivals at the Merge are ignored. ## What it outputs The payload from the arriving branch(es) is written to the Merge node's context. With `wait_all`, the context contains a merged view keyed by the source branch's node IDs. ## Gotchas - **Merge deadlock**: if an upstream branch never produces a result (e.g. it's gated by a `filter` that always drops), `wait_all` blocks indefinitely. Check your upstream routes end in a Merge input only when they actually deliver. - **Merge is re-entrant**: unlike most nodes, Merge can be entered multiple times during a single execution. The engine tracks arrivals per merge instance.