While Loop End
The off-ramp that stops the loop and hands you the goods
- flow
- initial_value_1
- initial_value_2
- initial_value_3
- initial_value_4
- initial_value_5
- initial_value_6
- initial_value_7
- initial_value_8
- initial_value_9
- initial_value_10
- initial_value_11
- initial_value_12
- initial_value_13
- initial_value_14
- initial_value_15
- initial_value_16
- initial_value_17
- initial_value_18
- initial_value_19
- initial_value_20
- value_1
- value_2
- value_3
- value_4
- value_5
- value_6
- value_7
- value_8
- value_9
- value_10
- value_11
- value_12
- value_13
- value_14
- value_15
- value_16
- value_17
- value_18
- value_19
- value_20
The while loop in PixNodes doesn't loop by jumping backward, because ComfyUI doesn't do that - it executes a graph forward. So to repeat a section, the pack does what Impact Pack's iteration machinery does: it rebuilds the graph. While Loop End is the node where that decision happens, and also where the loop's final values come out.
It's the bottom half of the pair. Pix_WhileLoopStart marks the top of the loop body; this node sits at the bottom, receives the Start's flow, checks the loop's continuation condition, and either ends the loop or runs it again.
How it works
Two required inputs: flow (FLOW_CONTROL, from the Start) and condition (BOOLEAN). When condition is false, the loop is done - the End returns whatever is sitting in its initial_value_1..20 inputs as value_1..20. Those inputs are wired to the outputs of the loop body's last iteration, so the values you get out are genuinely the final state, not a reset.
When condition is true, the interesting thing happens. The node uses ComfyUI's GraphBuilder to clone the entire loop body - it walks upstream from the Start, figures out which nodes actually live inside the loop (skipping nested loop End nodes so they don't get tangled), copies them, plugs the current values back into the Start's initial_value slots, and expands the graph so the body executes again. It does this through ComfyUI's dynprompt/unique_id hidden inputs, which is why you'll never see those on the canvas. Every true pass = one more copy of the body appended to the execution graph. That re-evaluation every pass is exactly what earns the "while."
What you wire
- flow (FLOW_CONTROL) and condition (BOOLEAN) - connect flow from the Start; feed condition from the same comparison the Start's condition uses (typically Pix_Compare or Pix_MathInt feeding the check).
- initial_value_1..20 (any type) - the loop body's results, wired back in. These become the outputs when the loop terminates.
- value_1..20 - the loop's final values. Wire these to whatever consumes the result: Save Image, a filename, another node.
The rule that keeps you sane
The condition has to be able to flip to false, and it has to flip eventually. Because each true pass unrolls another copy of the body, a condition that never turns false doesn't spin forever - it builds the graph until ComfyUI runs out of memory or you kill it. Iterating on a counter? Put a hard cap (counter < 100 via Pix_Compare) in as a safety net even if you expect to break out earlier. And remember the cost of the mechanism: a while loop with 50 passes of a sampler is 50 samplers in the expanded graph. That's not a bug, it's how the feature works, so keep the body cheap and the pass count modest.
Install
It ships in Comfyui-PixNodes, the pack's loop section - no model downloads, and the only dependencies (openai, requests) aren't used by the loop nodes. Install via ComfyUI Manager by searching PixNodes, then restart. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/pixixai/Comfyui-PixNodes
cd Comfyui-PixNodes
pip install -r requirements.txt
Restart after. Two setup notes: the README's manual-install block points at the wrong repo (ComfyUI-AlignLayout - copy-paste error, use the URL above), and if your loop values come back empty or null, update the pack - v1.1.0 fixed "loop nodes' data not being transmitted." Both loop nodes get that fix, so keep them current before you blame your wiring.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| flow | FLOW_CONTROL | — | |
| condition | BOOLEAN | — | |
| initial_value_1opt | * | — | |
| initial_value_2opt | * | — | |
| initial_value_3opt | * | — | |
| initial_value_4opt | * | — | |
| initial_value_5opt | * | — | |
| initial_value_6opt | * | — | |
| initial_value_7opt | * | — | |
| initial_value_8opt | * | — | |
| initial_value_9opt | * | — | |
| initial_value_10opt | * | — | |
| initial_value_11opt | * | — | |
| initial_value_12opt | * | — | |
| initial_value_13opt | * | — | |
| initial_value_14opt | * | — | |
| initial_value_15opt | * | — | |
| initial_value_16opt | * | — | |
| initial_value_17opt | * | — | |
| initial_value_18opt | * | — | |
| initial_value_19opt | * | — | |
| initial_value_20opt | * | — |
Outputs (20)
| Name | Type | Description |
|---|---|---|
| value_1 | * | — |
| value_2 | * | — |
| value_3 | * | — |
| value_4 | * | — |
| value_5 | * | — |
| value_6 | * | — |
| value_7 | * | — |
| value_8 | * | — |
| value_9 | * | — |
| value_10 | * | — |
| value_11 | * | — |
| value_12 | * | — |
| value_13 | * | — |
| value_14 | * | — |
| value_15 | * | — |
| value_16 | * | — |
| value_17 | * | — |
| value_18 | * | — |
| value_19 | * | — |
| value_20 | * | — |