Skip to content

Fix OSError crash from print() on ComfyUI Desktop#118

Open
cuzelac wants to merge 1 commit intovisualbruno:mainfrom
cuzelac:fix/print-oserror-crash
Open

Fix OSError crash from print() on ComfyUI Desktop#118
cuzelac wants to merge 1 commit intovisualbruno:mainfrom
cuzelac:fix/print-oserror-crash

Conversation

@cuzelac
Copy link

@cuzelac cuzelac commented Mar 9, 2026

Summary

  • Replace all 25 print() calls in trellis2/pipelines/trellis2_image_to_3d.py with logging.info() to fix a crash when running workflows through the ComfyUI API
  • ComfyUI Desktop's --log-stdout flag wraps sys.stdout via comfyui_manager/prestartup_script.py, and its flush() raises OSError: [Errno 22] Invalid argument when the underlying pipe handle goes stale
  • Any bare print() during pipeline execution (e.g. model loading messages) triggers this and crashes mesh generation entirely
  • The crash does not occur when manually running workflows from the ComfyUI UI — only when submitting them via the API
  • logging.info() bypasses the broken stdout wrapper while still producing log output

Traceback

File "...\trellis2\pipelines\trellis2_image_to_3d.py", line 229, in load_image_cond_model
    print('Loading Image Cond model ...')
  → comfyui_manager/prestartup_script.py line 331, sync_write
  → original_stdout.flush()
  → OSError: [Errno 22] Invalid argument

Test plan

  • Restart ComfyUI Desktop and submit a workflow using Trellis2MeshWithVoxelAdvancedGenerator via the API
  • Confirm it no longer crashes at model loading and proceeds through inference
  • Verify status messages still appear in ComfyUI logs
  • Confirm manually-run workflows continue to work as before

🤖 Generated with Claude Code

…esktop

ComfyUI Desktop's --log-stdout wraps sys.stdout, and its flush() raises
OSError: [Errno 22] when the pipe handle goes stale. All 25 print() calls
in the pipeline now use logging.info() which bypasses the broken wrapper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant