Skip to content

fix: handle websocket errors gracefully in comfy run#384

Merged
bigcat88 merged 2 commits into
mainfrom
fix/graceful-websocket-errors
Mar 15, 2026
Merged

fix: handle websocket errors gracefully in comfy run#384
bigcat88 merged 2 commits into
mainfrom
fix/graceful-websocket-errors

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

When using comfy run --workflow with long-running workflows, websocket errors (timeouts, connection drops) would crash with unhandled Python tracebacks. This made it hard to understand what went wrong and how to fix it.

Added exception handling in execute() for WebSocketTimeoutException and general WebSocketException/ConnectionError. Timeout errors now print a clear message with a hint to increase --timeout. Connection drops print the specific error reason. Both exit cleanly with code 1 and properly clean up the progress bar.

Tested against a local ComfyUI instance with forced timeout (0.001s), forced connection drop (socket shutdown mid-execution), and normal workflow completion. All three paths produce clean output instead of tracebacks.

Fixes #200

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #384      +/-   ##
==========================================
+ Coverage   63.89%   66.59%   +2.70%     
==========================================
  Files          33       33              
  Lines        3700     3706       +6     
==========================================
+ Hits         2364     2468     +104     
+ Misses       1336     1238      -98     
Files with missing lines Coverage Δ
comfy_cli/command/run.py 66.19% <100.00%> (+49.03%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bigcat88 bigcat88 force-pushed the fix/graceful-websocket-errors branch from 31f8cd2 to 72ac5b5 Compare March 15, 2026 11:19
@bigcat88 bigcat88 marked this pull request as ready for review March 15, 2026 11:31
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Mar 15, 2026
@bigcat88 bigcat88 merged commit 6c52c40 into main Mar 15, 2026
14 checks passed
@bigcat88 bigcat88 deleted the fix/graceful-websocket-errors branch March 15, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

comfy run --workflow WebSocketTimeoutException

1 participant