Nodes/ComfyUI-Stacker/StackPopString
ComfyUI Node

StackPopString

Grab the last saved string off the stack — or make the pop not destructive

By concarne000·Created about a year ago·Updated about a year ago· 10
StackPopString
    • STRING
    keydefault
    fallback_enabledfalse
    override_enabledfalse
    stackmodeNormal
    stackpath./ComfyUI/Stack/
    fallback_item
    override_item

    StackPopString is the counterpart to StackPushString: it reads a string back out of a stack and hands it to your graph as a STRING, ready to plug into a CLIP text encoder, a filename pattern, a metadata field, anywhere you'd use text. In a two-workflow setup where workflow A renders and B processes, this is how B learns the prompt A used without you retyping it.

    The input list looks intimidating at first - four required booleans and an enum - but you'll realistically touch two or three of them.

    The inputs that matter

    • key - the stack name (default "default"). Match it to the push side or you'll pop from a different stack than you think.
    • stackmode - Normal (newest, deleted after read), Peek (newest, left in place), Pop Bottom (oldest, deleted), Peek Bottom (oldest, kept). If you're wondering when to leave Normal: when you want each pushed value consumed exactly once, like draining a queue of prompts across runs.
    • fallback_enabled + fallback_item - an empty stack returns the fallback value instead of killing the run. Handy for the first run, when the stack has nothing in it yet.
    • override_enabled + override_item - bypass the stack and just output the override string. The author's example: you want to try a different prompt on the same already-pushed stack. Nothing gets consumed.

    The output is a single STRING - the popped value, ready to wire onward.

    How it works

    The stack is a folder of timestamped ._st files at ComfyUI/Stack/<key>/. The node sorts the files, picks the newest (or oldest, in the Bottom modes), reads it as text, and - unless you're in a Peek mode - deletes it. LIFO in, LIFO out, with a FIFO escape hatch and a no-delete escape hatch.

    If the key folder is missing or holds no string files and fallback_enabled is off, the node throws and your generation stops. That's the sharp edge: because Normal mode deletes after reading, a run that pops then errors downstream has permanently consumed that value. The README warns about exactly this - pops that happened before an exception stay popped.

    Install and gotchas

    Same as the rest of the pack, and painless:

    cd ComfyUI/custom_nodes
    git clone https://github.com/concarne000/ComfyUI-Stacker
    

    then restart. Or search "ComfyUI-Stacker" in ComfyUI Manager. No models, no real dependencies.

    Two things trip people up:

    1. The stack is one-shot by default. Reading a value consumes it. For values you want around every run, use Peek mode or push fresh each time.
    2. Empty stacks crash on default settings. For a first run, either push first or turn on fallback_enabled with a sensible default string. You'll hit this once and then remember.
    CategoryConCarne

    Inputs (7)

    NameTypeDefaultDescription
    keySTRINGdefault
    fallback_enabledBOOLEANfalse
    override_enabledBOOLEANfalse
    stackmodeCOMBONormal4 options: Normal, Peek, Pop Bottom, Peek Bottom
    stackpathoptSTRING./ComfyUI/Stack/
    fallback_itemoptSTRING
    override_itemoptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING