bug: fix check for server ready when using 0.0.0.0 as host (#9002)

* Fix check for server ready when using 0.0.0.0 as host

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* fix: add noqa comment to health check host assignment for clarity

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Jordan Frazier 2025-07-11 06:08:50 -07:00 committed by GitHub
commit 7a02842730
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 153 deletions

View file

@ -147,11 +147,15 @@ def set_var_for_macos_issue() -> None:
def wait_for_server_ready(host, port, protocol) -> None:
"""Wait for the server to become ready by polling the health endpoint."""
# Use localhost for health check when host is 0.0.0.0 (bind to all interfaces)
health_check_host = "localhost" if host == "0.0.0.0" else host # noqa: S104
status_code = 0
while status_code != httpx.codes.OK:
try:
status_code = httpx.get(
f"{protocol}://{host}:{port}/health", verify=host not in ("127.0.0.1", "localhost")
f"{protocol}://{health_check_host}:{port}/health",
verify=health_check_host not in ("127.0.0.1", "localhost"),
).status_code
except HTTPError:
time.sleep(1)

File diff suppressed because one or more lines are too long