Nodes/ComfyUI Functional/[Internal] Create Closure
ComfyUI Node

[Internal] Create Closure

The node you never place by hand (and shouldn't)

By Duanyll·Created 11 months ago·Updated 4 months ago· 2
[Internal] Create Closure
  • capture_0
  • CLOSURE
body
output
side_effects

If you search for this node, good chance you're confused about why it exists. Fair. [Internal] Create Closure is not something you build - it's something the pack's transform hook builds for you the moment you queue a workflow. Think of it as the compiled artifact of a function definition.

What it actually is

The whole ComfyUI Functional pack works by rewriting your graph behind the scenes. When you press Queue, the hook walks backward from every Function End node, separates the parts of the graph that depend on Function Parameter nodes from the parts that don't, and replaces the Function End with this node. The body of your function gets serialized to JSON and parked inside body; the return edge becomes the output JSON; the non-parameter stuff becomes a list of captured values under capture_0, capture_1, and so on.

So the inputs line up like this:

  • body - multiline string holding the JSON of the function's inner graph (machine-generated, don't hand-edit)
  • output - a string describing which edge is the return value
  • side_effects - a float; the hook sets it to NaN when the body contains Sow/Reap nodes so ComfyUI's cache gets busted and results stay honest, or 0.0 otherwise
  • capture_N - dynamically numbered inputs holding values captured from outside the function body

It outputs exactly one thing: a CLOSURE, the object that Call Function and the high-order nodes later consume.

Why you should leave it alone

Because the body/output are JSON blobs produced by the transform, hand-wiring this node is like hand-assembling bytecode. You'll see it in a saved workflow JSON if the file was already transformed, and you'll see it flash through if you watch the prompt that gets sent to the executor. In all normal usage you never place one - you place a Function End, and the hook turns it into this.

The only time it matters for debugging: if you ever see a Function End error saying it "should never be executed directly," that's the marker node running because the hook didn't rewrite it - usually a sign the pack's internal hook failed to load or ComfyUI updated and broke the scheduler integration. Which, per the README, is a known risk: this extension leans on hacky internals, and ComfyUI updates can invalidate them. Keep test workflows handy and file a bug report with a reproduction when it breaks.

Installing it

You don't install this node alone - it ships inside ComfyUI Functional (Duanyll/comfyui_functional). ComfyUI Manager: search "Duanyll/comfyui_functional". Manual:

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

No pip dependencies, no models to download. You'll also want the Basic Data Handling pack so you can feed LIST values to the functional nodes. If you only ever run stock ComfyUI, this node does nothing visible for you - that's expected.

Categoryduanyll/functional/internal

Inputs (4)

NameTypeDefaultDescription
bodySTRING
outputSTRING
side_effectsFLOAT
capture_0opt*

Outputs (1)

NameTypeDescription
CLOSURECLOSURE