Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Serve] Add more nuanced checks for http proxy status errors #47896

Merged
19 changes: 12 additions & 7 deletions python/ray/serve/_private/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,8 +999,7 @@ async def send_request_to_replica(
status_code = str(asgi_message["status"])
status = ResponseStatus(
code=status_code,
# TODO(edoakes): we need a more nuanced check than this.
is_error=status_code != "200",
is_error=not status_code.startswith("2"),
)
expecting_trailers = asgi_message.get("trailers", False)
elif asgi_message["type"] == "websocket.accept":
Expand All @@ -1022,11 +1021,17 @@ async def send_request_to_replica(
if not asgi_message.get("more_trailers", False):
response_generator.stop_checking_for_disconnect()
elif asgi_message["type"] == "websocket.disconnect":
status = ResponseStatus(
code=str(asgi_message["code"]),
# TODO(edoakes): we need a more nuanced check than this.
is_error=False,
)
status_code = str(asgi_message["code"])

# Check based on standard WebSocket status codes
if status_code in ["1000", "1001"]:
# Normal closure or going away, no error
is_error = False
else:
# Other 1xxx codes are specified as errors
is_error = status_code.startswith("1")

status = ResponseStatus(code=status_code, mis_error=is_error)
Superskyyy marked this conversation as resolved.
Show resolved Hide resolved
response_generator.stop_checking_for_disconnect()

yield asgi_message
Expand Down