Skip to content
Docs

Handling errors

By default a node that fails for good stops the run, and the run is recorded as failed. This page shows you the four ways to do something else, how to choose between them, how a run that got past a failure reads, and how to rehearse a failure before a real one finds the gap.

A node fails for good after its last attempt: three attempts, with a pause between them, for a call that can be retried (see Handle unreliable APIs for what is retried and what is not). A setting that cannot be worked out, such as a bad expression, fails at once without retries.

What happens Use it when
Continue The node finishes with an error envelope as its output and the run goes on along its normal path. The next node can cope with a bad answer, or the failure of one call should not matter to the rest.
A node’s error port The run leaves the failed node by its On error port and follows that path instead of the normal one. One node needs its own answer to a failure: try another source, write a fallback, tell someone.
The flow’s error branch One path behind Start catches every node that has no error port of its own wired. You want one alert or clean-up for the whole flow.
A watcher flow A separate flow starts whenever a run of any flow in the workspace fails. You want one alert, or one repair agent, for every flow at once.

The first three are decisions inside a flow. The fourth lives outside the flows it watches.

Set On error under More settings on a Rest / Operation or OpenApi / Operation node to Continue with an error envelope. The node completes, and its output says what went wrong:

{ "error": true, "upstreamStatus": 503, "message": "Server error: 503 ..." }

A node after it reads $prev->error and decides. The run reads Completed, and the node reads Done: it returned, so nothing marks it as a failure except a note on the run, “Continued on error, past: …”. The full envelope and how to branch on it are in Handle unreliable APIs.

A node set to continue never reaches its error port or the flow’s error branch for a failed call, because for that call it did not fail. Only a failure that continue does not cover still goes there.

A Subflow can continue too, past a flow it runs that failed, and so can a Parallel set to continue on an item’s error, past an item that failed. Each finishes with an error envelope in place of what failed and the run goes on, but something inside it did fail, so the run reads Handled, not Completed, and appears in the Handled view.

Most nodes have an On error port on their right edge, under the normal output. Connect a node to it, or click it to choose one, and that node runs when this one has failed for good. Agents, Subflow, the pagers and Parallel have the port too. A Form has one for the failure to make its link, as long as the Form is not published as a page. Conditional Exit, Switch and the triggers have none, and neither has a node that only plugs into an agent as a tool, memory or model.

Example. A Rest / Operation node fetches carrier statuses. Connect its error port to a Slack node that says the carrier feed is down. The run follows the error path, tells the office, and ends. The Slack node reads the failure as $prev:

Carrier feed failed: {{ $prev->message }} (after {{ $prev->attempts }} attempts)

$prev carries message, upstreamStatus, circuitOpen, attempts, the failed node as node, and input, what the failed node was given. When circuitOpen is true the call was refused because the host was already known to be down, so a branch can say “the carrier is down” once instead of once per call.

A node’s error branch is its own path. It does not merge back into the main one, and it cannot read the failed node’s output with node("Fetch statuses"), because there is none. Read $prev.

Start has an On error port too, and it means something different: not where Start’s own failure goes, since Start never fails, but where the flow’s error branch begins. Connect one node to it, and that branch catches every node that has no error edge of its own. A node with its own edge still uses it. A flow has one such branch.

Example. A flow reads orders, maps them and writes them to a table. Connect Start’s error port to a Mail node. Whichever of the three nodes fails, the office gets one mail, and the branch runs once, after the rest of the run.

When several nodes failed, the branch reads one $prev with the first failure as above, plus a failures list with every failure in order. $start is untouched, so the branch still knows which order or message it was handling.

While you hover Start’s port, the nodes it catches light up, and its label counts them.

What the flow’s error branch cannot catch

Section titled “What the flow’s error branch cannot catch”
  • A run stopped by hand. Someone chose that, so nothing handles it.
  • A run that never starts, because it was refused when it was started. There is no run to have a branch.
  • A failure inside the flow’s error branch itself. A branch that fails fails the run, so a broken alert cannot loop.
  • A node set to continue, for the failures continue covers. It never fails.
  • A node inside a pager’s or a split’s body, directly. Its page or item fails, and what the branch catches is the pager’s or the split’s failure.
  • Nodes the run never walks: what plugs into an agent as a tool, memory or model. A tool that throws fails the agent, and the agent’s failure is what the branch catches.

A Form’s failure to make its link is caught. Failing to send the link is not a failure of the Form: the Form waits, and you can send a new link from the run.

A split that cannot start is caught too, as a failed item is: one whose path to its list matched no list, or that has no body. It goes to its own error port, or to the flow’s error branch.

A node that times out is caught, but late. Each attempt that times out waits about an hour before it is tried again, so after three such attempts the error path can start up to about two and a half hours after the node did.

Adding the error branch changes what a Fail node means

Section titled “Adding the error branch changes what a Fail node means”

Without Start’s error edge, a Fail the run node stops the run as failed. With it, a Fail node in the flow is a failure like any other: the error branch takes it, and the run ends as Handled, not Failed. Adding that one edge to a flow that has run for months changes what its Fail nodes do, and what your alerts see.

To end a handled run as failed on purpose, put a Fail node at the end of the error branch. A failure inside the branch has nowhere to go, so the run fails there.

A flow that starts with When a Run Finishes, with Flow left empty, watches every flow in the workspace. Use it for one alert or one repair agent for everything. It starts at most once per cooldown for each watched flow, and it hears about failed runs, which is also the catch: a run whose error was handled completed, so a watcher set to failed runs does not start for it. Tick Completed runs as well if you want to hear of handled ones. Their $start->payload->run->status is completed, the same as a clean run’s, so tell them apart by $start->payload->run->handled, how many nodes’ failures an error path took (0 for a clean run), and $start->payload->run->handledAt, the first of those nodes. A failure a Subflow or a Parallel continued past is not in that count.

  • A call that may fail and does not matter: continue.
  • A node whose failure needs its own answer: its error port.
  • The same answer for any node: the flow’s error branch, with an error port only where one node differs.
  • An alert for every flow, including ones you have not written yet: a watcher flow.
  • Both a branch and a watcher: the branch deals with the failure and the run completes. The watcher hears of failed runs only, so keep the error branch ending in a Fail node when you want the watcher to fire too.

Without any of these, a failed run alerts the workspace owners. A handled run does not, because it did not fail. If a branch is your alert, make sure it sends one.

The words are the same on the canvas, in the runs list and on the run page.

  • Retrying: a node failed, and another attempt is coming. The run goes on. The canvas shows the countdown to the next attempt, and the run page lists each attempt.
  • Handled: the run got past a failure. A node failed for good and its error path took over, or a Subflow or a Parallel set to continue went on past a flow or an item that failed inside it. Red Failed keeps one meaning, the run stopped here. A Handled run ended as Completed, so a handled run still appears under Completed in Runs; the Handled view lists just these.

On a run page the verdict says which node failed and where it went, for example “Fetch statuses failed after 3 attempts. The flow’s error branch took over at Tell the office.” Under the node’s own card the failure and a link to the branch are shown, and the branch’s first card says which node’s failure it ran because of. If a run failed in an error branch, its heading says so. See Runs & debugging.

An error path that has never run is a guess. Rehearse it before a real failure tests it.

  1. Save the node, then choose Rehearse a failure of the saved node at the foot of its settings. The rehearsal runs your draft as it is saved. The settings close for it, and changes you have not saved are discarded.
  2. The dialog says which input the run starts with: the input of the flow’s newest run, and when that run started, or an empty input if the flow has not run yet.
  3. On a node that calls a service, choose the failure to play: An error, or The service it calls is paused, which fails the node as when calls to its host were stopped after repeated failures, so the error path reads $prev->circuitOpen as true. Any other node plays an error.
  4. Leave Let the run act for real off to start, and choose Rehearse. A run of your draft starts, shown on the canvas, and goes down the node’s error port, or the flow’s error branch.

A rehearsal makes the node fail without calling anything at that node. At an agent, a Subflow, a pager or a split, or a node that waits for an answer (an Await, or a Form that asks), it fails before any of it starts: no model is asked, no flow, page or item is started, no link is made, and the run waits for nobody. The run page says so (“A rehearsal: … Nothing was called at that node.”), and the runs rail and the runs list mark the run rehearsal. If the run ends before it gets to the node, because a node before it failed or a Switch took another branch, the run page says the node was never reached, so nothing was made to fail.

  • With Let the run act for real off, nodes that would write or send say what they would have done. On, every node the run reaches acts for real: the nodes before the failed one, any branch beside it, and the error path after it. Only what follows the failed node’s own output does not run. Those nodes act on that newest run’s input a second time: a row that run wrote is written again, a mail it sent is sent again. The dialog says so when you turn it on.
  • It sends no alert and starts no watcher flow, and it is not counted when Publicus decides whether a flow keeps failing.
  • It fails the node once, with no retries. Inside a pager’s or a split’s body, the node fails on every page or item that reaches it, and its error path runs once for each: a split over 200 items runs it 200 times, and with Let the run act for real on, a message it sends goes out 200 times. The dialog says so for a node in a body.
  • A rehearsal that works reads Handled, like a real one. The run page, the rail and the runs list are where it says it was a rehearsal.
  • Re-run on a rehearsal’s run page repeats the rehearsal: the same node is made to fail again, as the same failure, on the same input, with your draft as it is now, and with Let the run act for real off, whatever the first run had. The confirm says so.

The button is not shown on Start, on a trigger, on a node that plugs into an agent as a tool, memory or model, on a node a Form sends its link through, on a Form published as a page, or on a node no path from Start reaches: none of them has a failure of its own for the flow to route. On other nodes it is shown and cannot be pressed when the node cannot be rehearsed, and its tooltip says why:

  • The node has no error path. Connect something to its error port, or to Start’s, which catches every node on the flow’s main path. A node with no error port of its own, such as a Switch, can only be caught by Start’s.
  • The node is inside a pager’s or a split’s body and has no error edge of its own. Start’s error port does not reach inside a body: a failure there fails its page or item, and what an error path can take is the pager’s or the split’s failure. Connect the node’s own error port, or rehearse the pager or split instead.
  • The node is set to continue on an error. Its failed call never takes an error path, so set its On error to fail first.
  • The node is in another node’s error path, or in the flow’s error branch. A run gets there only after another node has failed, so rehearse that node instead.