Skip to content

fix(comfyui): short connect timeout for loopback health probes - #934

Open
AdvaithSai wants to merge 1 commit into
OpenMontageInc:mainfrom
AdvaithSai:fix/windows-onboarding
Open

AdvaithSai wants to merge 1 commit into
OpenMontageInc:mainfrom
AdvaithSai:fix/windows-onboarding

Conversation

@AdvaithSai

@AdvaithSai AdvaithSai commented Nov 10, 2026 •

Copy link
Copy Markdown

Summary

On Windows, a connection to a closed port is retried for about 2s per address instead of failing at once, and localhost resolves to both ::1 and 127.0.0.1. So with no ComfyUI server running (the default for most users), each ComfyUIClient.is_available() probe takes about 4s. The registry probes once for each of comfyui_image, comfyui_video and comfyui_music, plus once each for image_selector and video_selector, so preflight spends about 20s waiting for a server that isn't there.

A server on the same machine completes the TCP handshake in well under a millisecond, so the health probe now uses a 0.5s connect timeout for loopback hosts (localhost, 127.0.0.0/8, ::1). Remote ComfyUI servers keep the 5s connect timeout, and the read timeout stays at 5s everywhere, so a busy local server that is slow to answer /system_stats is still detected.

Related issue

Refs #756 (one part of the "too slow" complaint; the docs and permission parts of that issue are not addressed here)

Changes

  • tools/_comfyui/client.py: new _probe_timeout() that returns (0.5, 5) for loopback hosts and (5, 5) otherwise; is_available() uses it.
  • tests/contracts/test_comfyui_tools.py: parametrized test covering localhost, 127.0.0.1, [::1], a LAN IP and a remote hostname.

Testing

Windows 11, Python 3.12, no ComfyUI running:

Before After
ComfyUIClient("http://localhost:8188").is_available() 4.08s 1.02s
each of the 5 ComfyUI-related get_status() calls ~4s ~1s
registry.provider_menu() (preflight) 41.8s 18.9s
  • A stand-in HTTP server on 127.0.0.1:8188 returning 200 is still detected (0.52s via localhost, 0.02s via 127.0.0.1).
  • pytest tests/contracts/test_comfyui_tools.py tests/tools/test_new_video_model_support.py tests/tools/test_provider_refresh.py → 184 passed.
  • Not run on macOS/Linux. There a refused connection fails immediately, so behaviour there should be unchanged.

Checklist

  • The change is focused on a single logical concern.
  • I ran the relevant tests locally (make test-contracts / make test) where applicable.
  • I updated docs/README if behavior or usage changed. (no usage change)
  • No unrelated files (build artifacts, local config) are included in the diff.

On Windows a connect to a closed port is retried for ~2s per address
instead of failing at once, and localhost resolves to both ::1 and
127.0.0.1. With no ComfyUI server running, every is_available() probe
cost ~4s, and the registry probes it once per ComfyUI tool and selector,
so preflight spent ~20s waiting on a server that isn't there.

A local server completes the TCP handshake in well under a millisecond,
so use a 0.5s connect timeout for loopback hosts. Remote servers and the
read timeout keep 5s. Preflight on Windows drops from ~42s to ~19s.

Refs OpenMontageInc#756
@AdvaithSai
AdvaithSai force-pushed the fix/windows-onboarding branch from d41cf03 to 220e480 Compare November 10, 2026 08:49
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