Nodes/Boyonodes/Boyo While Loop End
ComfyUI Node

Boyo While Loop End

The other half of the loop — where the 'while' actually happens

By DragonDiffusionbyBoyo·Created 2 years ago·Updated 26 days ago· 16
Boyo While Loop End
  • flow
  • initial_value0
  • initial_value1
  • initial_value2
  • initial_value3
  • initial_value4
  • initial_value5
  • initial_value6
  • initial_value7
  • initial_value8
  • initial_value9
  • value0
  • value1
  • value2
  • value3
  • value4
  • value5
  • value6
  • value7
  • value8
  • value9
condition
loop_id1
reset_signal0

A while loop in ComfyUI is a promise you make with two nodes, and Boyo While Loop End is where the promise is kept. Its Start counterpart declares the loop and carries the initial values; the End node is the one that looks at the continue condition after every pass and decides: re-queue the loop body, or let it finish and emit the final values. It's the reimplementation of EasyUse's whileLoopEnd that closes the Boyonodes loop pair without dragging in EasyUse itself.

You reach for this when your iteration isn't a fixed count but a condition: keep generating video chunks until you've covered the target length, keep refining until a quality or loss metric crosses a threshold, keep upscaling until the result is good enough. For fixed-count iteration the pack's for-loop nodes are the better fit; this is for "until X happens."

How it works

The End node receives the flow token from the Start node (it's really a cache key for the loop's state), the same loop_id, and a fresh condition BOOLEAN - which is where your loop body's logic plugs in. If the condition is false, the loop is done and it returns whatever initial_value0initial_value9 you provided, so the final state falls out of the outputs. If true, it re-executes the contained graph, cycling values back around. Like the Start node, it checks reset_signal: a changed value wipes the loop's cached state so the next run starts from scratch rather than resuming stale state.

Both nodes in the pair keep values in an in-memory cache keyed by loop_id - that's the trick that makes cycles possible at all in a graph engine that officially doesn't have them. It also means the two nodes must agree on loop_id, and that the state doesn't survive a ComfyUI restart.

The inputs that matter

  • flow - wire this from the matching Start node's flow output. Get this wrong and nothing cycles.
  • condition - the loop terminator. When it's false, the loop exits and outputs the initial values.
  • loop_id - must match the Start node.
  • reset_signal - change it to force a clean loop on the next queue.
  • initial_value0–9 - any type; these pass through and become the final outputs on exit.

The ten outputs, value0value9, are what your loop body reads after each iteration (and, on exit, the final state). There's no flow output here - that's the Start node's job.

Install

Same as the rest of the pack - ComfyUI Manager under "Boyonodes", or git clone https://github.com/DragonDiffusionbyBoyo/Boyonodes into ComfyUI/custom_nodes/, then restart. No models, no extra pip packages.

Where people get burned

The whole family of loop nodes shares the same traps: a loop_id mismatch between Start and End, a condition that never goes false (infinite loop - make sure something in the body can actually flip it), and the in-memory cache that dies with a restart. Also worth knowing: these are exact replications of the EasyUse logic, so they behave the way EasyUse loops do - don't mix Boyo and EasyUse ends in the same loop, and if the pack's notes sound cautious about complex graphs, that caution is earned.

CategoryBoyo/Logic/While Loop

Inputs (14)

NameTypeDefaultDescription
flowFLOW_CONTROL
conditionBOOLEAN
loop_idINT11–999
reset_signaloptINT0
initial_value0opt*
initial_value1opt*
initial_value2opt*
initial_value3opt*
initial_value4opt*
initial_value5opt*
initial_value6opt*
initial_value7opt*
initial_value8opt*
initial_value9opt*

Outputs (10)

NameTypeDescription
value0*
value1*
value2*
value3*
value4*
value5*
value6*
value7*
value8*
value9*