Compare commits

...

2 Commits

Author SHA1 Message Date
Octopus
13d14251df
Merge 579a9263ea into 3e3ed8cc2a 2026-05-02 09:08:29 -07:00
octo-patch
579a9263ea fix: guard LogInterceptor.flush() against OSError on Windows no-console setups (fixes #13554)
On Windows, when ComfyUI is launched without an attached console (e.g.
from a desktop shortcut or detached process), sys.__stdout__ may point
to an invalid console handle. Calling flush() on such a handle raises
OSError: [Errno 22] Invalid argument, which propagates up through any
code that calls print() and crashes every prompt execution.

Wrap super().flush() in LogInterceptor.flush() with the same
try/except (OSError, ValueError): pass pattern that is already used
elsewhere in the codebase for exactly this scenario. A failed flush on
a broken console handle just means the line isn't force-drained to that
console; content still reaches log_file and the in-memory log buffers.

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
2026-04-27 10:41:38 +08:00

View File

@ -32,7 +32,10 @@ class LogInterceptor(io.TextIOWrapper):
super().write(data)
def flush(self):
super().flush()
try:
super().flush()
except (OSError, ValueError):
pass
for cb in self._flush_callbacks:
cb(self._logs_since_flush)
self._logs_since_flush = []