mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2026-11-05 07:47:25 +00:00
[GH-ISSUE #3223] tqdm progress bar BrokenPipe silently discards completed generations in background/MCP mode #1122
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/ComfyUI-Manager#1122
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Chaos2-lgtm on GitHub (Aug 29, 2026).
Original GitHub issue: https://github.com/Comfy-Org/ComfyUI-Manager/issues/3223
BrokenPipe — tqdm progress bar kills valid generations in background + MCP/API mode
Summary
When ComfyUI is launched in background / non-interactive mode (which is how the
official MCP + API / agent-driven usage is meant to run) and you submit a prompt that
contains a
KSampler, the generation actually completes, but the tqdm progress-barrenderer writes to a severed stderr pipe during sampling, raises
BrokenPipeError, andthat exception propagates up the execution chain — flagging the whole prompt as
status_str: "error". The finished image is never saved. A fully valid generation issilently discarded because the display layer crashed.
Environment
0.34.0(WSL2 / Linux)d47c9346 "update DB") — bug present at HEADpython main.py --listen 127.0.0.1 --port 8188(stderr redirected to a closed pipe)/prompt(same occurs via comfy MCP; both go through the same API)Reproduce
KSamplertohttp://127.0.0.1:8188/prompt.GET /history/<prompt_id>. Observe: and no output image in/history/<id>/outputs.Prompt executed in 5.83 secondsRoot cause
The traceback funnels through:
ComfyUI-Manager's
prestartup_script.pyinstalls a stream wrapper that re-emits tqdmprogress to
original_stderr. In background/detached mode the stderr pipe's read end hasalready been closed, so each progress-bar refresh raises
BrokenPipeError. Because thishappens inside the sampler loop, the exception is not contained — it bubbles all the way
up and marks the entire job failed, even though sampling succeeded.
Why this matters (official direction)
Background + MCP/API is the officially promoted way to drive ComfyUI (agents, automation,
headless servers). In that mode stderr is commonly redirected, so every KSampler job is
at risk of this. It is not an exotic one-off.
Suggested fix (minimal, display-only)
Workaround (no code change)
Launch with stderr pointed at a real file/terminal, or ignore the error server-side —
but the honest fix is the two-line guard above, so completed generations are not dropped.
Filed from a background-launched, MCP-driven ComfyUI instance; patch verified locally
(ad-hoc py_compile + severed-pipe behavioural probe pass; generation returns
successandsaves PNG after applying the guard).
以上內容是由Agent代為總結。