Learn

Architecture & pattern guides

Read the idea, build it on a Grid, prove it in a challenge. Short, practical guides — illustrated with RodGrid's own nodes — on system design, design patterns, flow modeling, and how to get the most out of the app.

All articles

Loops & retries

Build a loop by feeding a decision's branch back through a Merge, then give it an exit and a pause between attempts.

The edge that will not connect

You have Start → Attempt → Success?, and you want the decision's no branch to go back and try again. Drag that edge onto Attempt and the Grid refuses it: Attempt already has its maximum of 1 incoming connection. A loop repeats a step until a condition holds, so the repeated step has to be reachable from two places, the first entry and the way back, and on the Grid a normal step accepts only one incoming edge. The fix is a Merge in front of it, the node Merge & path convergence is about. A Merge takes up to four inputs and passes the flow on through one output, so both entries go into the Merge and only the Merge goes into Attempt.

Retry loop via Merge

Read the diagram from the top. Start enters the Merge at in-1. The decision's no branch leaves by the diamond's side (a Decision's two exits are covered in Decisions & branching), climbs past the column and comes back into the Merge at in-4, its right-most input, so the loop-back has a port of its own and does not land on Start's. Give the two entries separate ports: two edges on one port are drawn on top of each other, and the reader can no longer see that the step has two ways in. Pointing the loop-back straight at Attempt is the mistake the refusal above catches.

A way out, and a limit

The loop in the diagram leaves only through yes. That is enough for a loop whose condition someone outside it keeps working towards, like a player guessing a number. A retry loop is different: it exists because the thing it calls is failing, and a dependency that stays down never answers yes, so the flow goes round forever. So a retry loop needs a second exit, a cap on the attempts. One way is a pair of Loop Limit nodes that bracket the repeated steps and name the bound ("Up to 3 attempts"), with no loop-back edge at all; Predefined process, data & loops teaches that pair. With a Merge loop like this one, put a second Decision on the retry branch, before the edge reaches the Merge:

  1. Success? answers no.
  2. Attempts left? compares the attempts made so far with the maximum, say three in total; the count starts at zero and goes up by one each time Attempt runs.
  3. If attempts remain, the flow pauses, then re-enters the Merge.
  4. If none remain, the flow leaves the loop for an explicit failure path that ends at its own End.

That failure path is where an exhausted retry gets handled instead of vanishing, often through an Error Boundary as Error handling & error boundaries draws it.

A pause between attempts

Retrying the instant a call fails sends the next request into the same overloaded or broken dependency, and a few hundred clients doing that together can keep it down. A Delay node (one of the stencils in Connectors, off-page links & delays) on the retry branch, labelled with how long it pauses ("wait 2 s"), models that pause; waiting longer after each failed attempt is the usual form of backoff. How backoff and retry limits behave in a running system, jitter included, is the subject of Retry.

TipLabel every edge out of a Decision with its condition and every Delay with its duration: no, "attempts left", "wait 2 s".

Draw the full retry

The Retry with Backoff Flow challenge asks for all of this inside a ten-node budget: an attempt, a success check, a Delay, a cap and an error path. The part to get right first is the loop-back edge returning to the Merge in front of the repeated step, not to the step itself. Then trace both endings: one End on success, and a separate failure End once the attempts run out. Number Guessing Loop is the smaller version, a loop that only ends when the guess is right; Subscription Dunning Flow caps its retries with a loop limit and pauses on a schedule between them.

Practice this