Nodes/AsyncOutput/BatchIterator String Callback
ComfyUI Node

BatchIterator String Callback

Read the gathered strings when the emitter says it's time

By teddy1565·Created 5 months ago·Updated 5 months ago· 0
BatchIterator String Callback
    • output_list
    emitter_result
    key_id
    reset

    BatchIterator String Callback (class BatchIteratorStringCallback) is the read-out half of the BatchIterator family's gather pattern - the node that finally returns the list of strings the String Collection nodes have been stashing, but only when the String Emitter says the loop is done. Same "Promise.all callback" role as AsyncOutputCallback, running against the BatchIterator family's own dictionaries.

    It's the node that makes "gather N results, then do something with all of them" executable in ComfyUI, because ComfyUI has no if and no wait-for-events. The trick is the same comfy_execution.graph.ExecutionBlocker: when emitter_result is false, the callback returns a blocker, and everything downstream just doesn't run that pass. Not an error, not a crash - a quiet "not yet." When the emitter finally fires true, the callback hands over the whole accumulated list and downstream gets to run.

    How it works

    On each execution: reset true → delete the stored list for key_id and block. emitter_result false → block. emitter_result true with no stored data → block (nothing gathered yet). emitter_result true with data → return ASYNC_OUTPUT_BATCH_ITERATOR_STORAGE_DATA_DICT[key_id] as the output list. One notable difference from its AsyncOutput cousin: it doesn't delete the data after reading it. AsyncOutputCallback removes the record on read; this one leaves it in place, so a later execution of the callback can read the same list again. That's friendlier for re-running a workflow but means you can double-fire if your emitter isn't one-shot.

    The inputs that matter

    • emitter_result (BOOLEAN, forced) - wire from a BatchIteratorStringEmitter's emit_result.
    • key_id (STRING) - must match the Collection and Emitter.
    • reset (BOOLEAN, optional) - clears this key's stored list and blocks.

    Output: output_list (LIST) - the gathered strings, in append order.

    Installing it

    No dependencies, no model files. ComfyUI Manager → search "AsyncOutput" → install and restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/teddy1565/ComfyUI-AsyncOutput
    

    It's under AsyncOutput/BatchIterator/String.

    Where people get burned

    The no-delete behavior is the main gotcha - if your workflow can hit this node twice with a true emitter, you'll get the same list twice, which is usually not what you want downstream of a "combine all results" step. And because it blocks downstream by design, a callback sitting on false can look like a broken workflow: the thing you expected to run just doesn't. Check the emitter's count and conditions before assuming something's wrong. The data also still lives in process memory and gets auto-wiped per the BatchIterator family's reset flag, so plan around a restart if your gather needs to outlive the process.

    CategoryAsyncOutput/BatchIterator/String

    Inputs (3)

    NameTypeDefaultDescription
    emitter_resultBOOLEAN
    key_idSTRING
    resetoptBOOLEAN

    Outputs (1)

    NameTypeDescription
    output_listLIST