Break break
Exit the enclosing Loop immediately. Calls Memory.SignalBreak() to set a break flag, which the Loop node detects to stop iteration and fire its done port. Zero configuration required — placement inside a Loop body is the only requirement.
When to Use
- Find-first search: Loop over a list of pricing rules, records, or suppliers and exit immediately when the first match is found — no need to evaluate remaining items.
- Stop on first validation failure: Validate cart items or form fields in sequence; as soon as one fails, Break exits the loop and routes to an error response without processing the rest.
- Stop on successful external API match: Query multiple fallback APIs in priority order; Break as soon as one returns a successful response, abandoning the cheaper alternatives.
- Error-triggered early exit: If a critical item in a data import fails (missing required field, data integrity issue), Break stops the loop before processing dependent items that would fail for the same reason.
Configuration
false or matching port of an IfCondition node). It executes and signals the loop the moment it is reached.
How It Works
When a Break node executes, it calls Memory.SignalBreak(), which writes a break signal into ExecutionMemory. The enclosing Loop node monitors for this signal after each body iteration. On detecting the signal, the Loop node:
- Stops firing the
bodyport for any remaining items in the array. - Clears the break signal from ExecutionMemory.
- Fires its
doneport to continue the workflow with post-loop logic.
All variables and output data accumulated during completed iterations remain intact and accessible on the done port path.
Output Ports
| Port | Notes |
|---|---|
| none | The Break node has no output port of its own. It signals the enclosing Loop, which then fires its own done port. Do not connect any downstream node directly from Break — execution continues from the Loop's done port. |
OutputData Fields
Break itself writes no output data fields. After a Break exits the loop, the Loop node's done port output data reflects the state at the time of the Break:
| Field (on Loop node) | Type | Description |
|---|---|---|
current_index | int | The 0-based index of the item at which the Break fired — i.e., the last item that was fully or partially processed. |
collection_size | int | Total number of elements in the original array (unchanged by the early exit). |
items | array | The full original array. |
Placement Requirements
body port. If Break is executed outside a loop context, the engine raises a runtime error: ERR_BREAK_OUTSIDE_LOOP. There is no configuration that makes Break valid outside a loop.
Node Policies and GuardRails
- Always pair with a condition: Break should almost always be connected from the output of an IfCondition node. An unconditional Break in the body would exit the loop on the first item every time, which is equivalent to not looping at all.
- Post-loop logic on the done port: All work that should happen after the loop exits — whether by normal completion or by Break — must connect to the Loop's
doneport, not to Break directly. - Variable state is preserved: Variables set during completed iterations before the Break are fully accessible on the
doneport path. Use VariableAssignment nodes inside the loop body to accumulate the match result before Break fires. - Break does not propagate errors: Break is a clean, intentional exit — it does not set any error state. Downstream nodes on the
doneport treat this as a normal loop completion.
Pattern Examples
Pattern 1 — Find-First Match (Rule Engine)
Loop over prioritised pricing rules. The first rule that matches the order is captured, then Break exits the loop. Downstream logic uses only the first-matched rule.
VariableAssignment [key: "initMatch"]
matchedRule = null
└─► Loop [key: "evalRules"]
Items: {{ $var.pricingRules }}
├─► body ──► IfCondition [key: "checkRule"]
│ Condition: {{ $var.current_item.minAmount <= $json.orderTotal &&
│ $var.current_item.tier === $json.customerTier }}
│ ├─► true ──► VariableAssignment (matchedRule = current_item)
│ │ └─► Break
│ └─► false ──► (end of iteration — loop advances to next item)
└─► done ──► IfCondition
Condition: {{ $var.matchedRule !== null }}
├─► true ──► [apply matched rule discount]
└─► false ──► [apply default pricing]
Pattern 2 — Cart Validation with Early Stop
Check stock for each cart item. Exit as soon as any item is out of stock, returning an error to the user without unnecessary API calls for remaining items.
Loop [key: "validateCart"]
Items: {{ $json.cartItems }}
├─► body ──► HttpRequest [key: "stockCheck"]
│ GET /inventory/{{ $var.current_item.sku }}
│ └─► IfCondition
│ Condition: {{ $output.stockCheck.available === false }}
│ ├─► true ──► VariableAssignment
│ │ (outOfStockSku = $var.current_item.sku)
│ │ └─► Break
│ └─► false ──► (continue to next item)
└─► done ──► IfCondition
Condition: {{ $var.outOfStockSku !== null }}
├─► true ──► HttpRequest (POST /checkout/error, sku out of stock)
└─► false ──► [proceed to payment]
Pattern 3 — Supplier Fallback with First-Available
Try suppliers in preference order. Break as soon as the first available supplier is found. Use the captured supplier for the order without querying remaining suppliers.
VariableAssignment (selectedSupplier = null)
└─► Loop [key: "findSupplier"]
Items: {{ $var.supplierList }}
├─► body ──► HttpRequest [key: "querySupplier"]
│ GET {{ $var.current_item.apiUrl }}/availability
│ └─► IfCondition
│ Condition: {{ $output.querySupplier.inStock === true }}
│ ├─► true ──► VariableAssignment
│ │ (selectedSupplier = current_item)
│ │ └─► Break
│ └─► false ──► (try next supplier)
└─► done ──► [place order with $var.selectedSupplier]
Sample Output
Success Port
Break produces no data output. When the break condition is met, the loop exits and execution continues on the node connected to the loop's exit port. No JSON payload is emitted.
{
"_control": "break",
"_loopExited": true,
"_iterationIndex": 5,
"_reason": "Break condition met: found target record"
}
Expression Reference
| Expression | Description |
|---|---|
{{ $output.loopNode._control }} | Always "break" — confirms loop exited via Break. |
{{ $output.loopNode._iterationIndex }} | The iteration index at which the break occurred. |
{{ $output.loopNode._loopExited }} | true — indicates the loop did not run to natural completion. |