Nodes/ComfyUI-JDCN/LogicUtil_AOrBGate
ComfyUI Node

LogicUtil_AOrBGate

A logic gate that doesn't do what its name says — read this first

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_AOrBGate
  • input1
  • input2
  • BOOL

Here's the thing nobody tells you about LogicUtil_AOrBGate: despite the name, the shipped code returns True only when both inputs are truthy. That's an AND, not an OR. The docstring in the source says "Returns 1 if any input is True," and then the very next line implements input1 and input2. If you wire this up expecting a proper OR - fire when either side is true - it will silently do the opposite of your intention and you'll waste an hour debugging the rest of the workflow.

This isn't speculation or a bad download; it's the code in the repo. The class is a port of aria1th's ComfyUI-LogicUtils bundled into JDCN, and the bug came along in the port. That's also why the graph label is LogicUtil_AOrBGate - the original class name with the pack's LogicUtil_ prefix bolted on.

How it works

The inputs are exactly two: input1 and input2, both typed as * so they accept anything, both defaulting to 0. The output is a real BOOL. Truthiness is Python truthiness, same as the other gates in the family: nonzero numbers and non-empty strings count as true, 0 and empty strings don't.

What to do about it

So what do you actually do with it? Options, in order of how much I'd trust them:

  1. Use it as an AND. Since that's what it computes, you can wire it in anywhere you'd use LogicUtil_AAndBGate and it'll work identically. Irritating but harmless.
  2. Build your own OR with two inverters and the AND gate: NOT (NOT a AND NOT b) - De Morgan's law, three nodes, correct behavior.
  3. Test before you trust it. Throw a pair of static values at it and watch the output before relying on it in a shared workflow. If it ever gets fixed upstream, the code will match the name, and the node will change behavior under you - which is itself a reason to keep it isolated to a single spot.

The community wisdom about ComfyUI graphs applies double here: the ecosystem runs on third-party logic nodes and nobody audits the math. A node that's wrong in a non-obvious way is more dangerous than one that crashes, because a crash tells you immediately. For anything where a wrong branch means wasted generations or bad output, verify the gate with fixed inputs before you trust it in anger.

Install

Install is the usual JDCN routine: ComfyUI Manager → "Install Custom Node" → search JDCN → install → restart, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-JDCN
cd ComfyUI-JDCN && pip install -r requirements.txt

Only piexif on the requirements list, no models to fetch. And if you load someone else's workflow that uses this gate and it "works wrong," now you know why - check whether the author was compensating for the bug before you copy the pattern.

CategoryLogicUtil

Inputs (2)

NameTypeDefaultDescription
input1*0
input2*0

Outputs (1)

NameTypeDescription
BOOLBOOL