Nodes/fexli-util-node-comfyui/FEInterruptCondition
ComfyUI Node

FEInterruptCondition

Make ComfyUI stop when a condition is met

By fexli·Created 3 years ago·Updated about a year ago· 3
FEInterruptCondition
  • input
  • output
interruptfalse

ComfyUI has a big red "interrupt" button, and you click it when you're watching a generation go sideways and want it dead right now. FEInterruptCondition is that button, but automated: it interrupts the running job when some condition in your graph is true. You stop babysitting the queue; the graph decides when to pull the plug.

It's a niche node, but the niche is real. Think of a batch workflow that tries prompts until one hits a quality threshold (a blur detector, a color check, an aesthetic score from some other node pack), then should stop so you can eyeball the result. Or a long queue where you want to bail out the moment a specific seed produces garbage. Without something like this, you either sit and watch, or you let the whole queue run and waste hours.

How it works

The mechanism is almost embarrassingly simple: when interrupt is true, the node POSTs to http://localhost:<port>/interrupt - the same endpoint your browser's interrupt button hits. ComfyUI then cancels the current run. Your ComfyUI port is picked up automatically from the server's own args, so you don't configure anything.

It's built as an "always change" node (its IS_CHANGED returns NaN), meaning it re-evaluates every queue run rather than caching a result - which is what you want: the interrupt decision has to be made fresh each time.

Inputs:

  • input - any type, passed straight through. You don't need it for the interrupt itself, but ComfyUI executes nodes when their inputs are ready, so this is what forces the node to run at the right time in your graph. Chain the thing you're checking into it.
  • interrupt - the BOOLEAN that actually decides. true kills the job.

Output: output, an exact copy of input. So the node is also a legitimately useful pass-through when you want a tap point in a wire.

The catch you need to know

There's a structural gotcha with all condition-interrupt nodes, and it's ComfyUI's, not this node's: nodes are scheduled and executed in dependency order, and an interrupt only stops work that hasn't finished yet. If the expensive sampler runs before your condition node in the graph, the interrupt fires too late - the image's already generated. You have to position the logic so the check happens before (or during) the heavy lifting, or wire it to gate the sampler rather than interrupt after it. Read the pack's source if you're unsure; the whole file is ~30 lines.

Install

From the fexli-util-node-comfyui pack:

cd ComfyUI/custom_nodes
git clone https://github.com/fexli/fexli-util-node-comfyui
cd fexli-util-node-comfyui
pip install -r requirements.txt

Or ComfyUI Manager → search fexli-util-node-comfyui → install → restart. Requirements are just pycryptodome and sseclient-py; the README's config.yaml only matters for the pack's API-generation nodes.

It's not a node you'll use every day - it's a node you'll be very glad exists the day you need a 4-hour queue to stop itself.

Categoryfexli/utils

Inputs (2)

NameTypeDefaultDescription
input*
interruptoptBOOLEANfalse

Outputs (1)

NameTypeDescription
output*