ComfyUI Node

Latch

A pure ordering node, and that's the point

By Duanyll·Created 11 months ago·Updated 4 months ago· 2
Latch
  • signal
  • value
  • *

Latch looks like the most pointless node you've ever seen - and that's the trick. It takes two inputs, signal and value, and returns value. That's it. No transformation, no logic. But in ComfyUI, a node that returns one of its inputs unchanged is a dependency gate: it forces ComfyUI to compute signal before it can hand you value.

What it's really for

In a normal graph, execution order is determined by data flow - a node runs when its inputs are ready. The problem is when you have a value that conceptually depends on something running first, but the wires don't express that. You want "give me this image, but only after the model has finished loading," or "hand me this seed once the prep pass has run." Latch makes that dependency explicit: value doesn't arrive until signal has been produced.

This matters in the functional pack specifically because of its side-effect helpers. When you use Sow/Reap or Inspect inside a function, the pack disables ComfyUI's cache to keep results honest - and execution order suddenly becomes something you have to manage by hand. Latch is the cable tie you use to keep the ordering straight: chain it after a Sow, and the next stage can't start until the sow has happened.

The inputs

  • signal - any type; it's only there to gate execution.
  • value - any type; the thing you actually want passed through.
  • output - value, untouched.

There's no real mechanism beyond that. Look at the source and it's literally return (value,) - the ordering guarantee comes from the graph edge, not from Python. If you expected a "hold the last value" flip-flop latch (like an electronics latch), that's not this node; this one is a pass-through gate.

Where people get burned

  • Expecting it to store state. Latch does not remember anything. It passes the current value through, once. For accumulating results, that's Sow/Reap's job.
  • No signal chain. If nothing upstream feeds signal, the gate is meaningless - you've just built an expensive straight wire. Always make signal depend on the thing that must run first.
  • Confusing it with ordering via side effects. If your workflow uses side-effect nodes, remember the pack disables caching around them; Latch won't fix stale values on its own - clear the cache or restructure.

Installing it

Part of Duanyll/comfyui_functional (side_effects category). ComfyUI Manager: search "Duanyll/comfyui_functional", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/comfyui_functional
# restart ComfyUI

No models, no pip deps. It's a utility you'll reach for when a workflow gets fiddly about ordering - keep one in your back pocket, don't build your whole graph around it.

Categoryduanyll/functional/side_effects

Inputs (2)

NameTypeDefaultDescription
signal*
value*

Outputs (1)

NameTypeDescription
**