Skip to content

Commit

Permalink
Fix 'no response returned' RuntimeError during cancellation in BaseHT…
Browse files Browse the repository at this point in the history
…TPMiddleware.

If an incoming request is disconnected before a response gets produced, don't
raise a RuntimeError.
  • Loading branch information
jonathanslenders committed Feb 16, 2024
1 parent 7533b61 commit cd26b14
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions starlette/middleware/base.py
Expand Up @@ -163,6 +163,8 @@ async def coro() -> None:
except anyio.EndOfStream:
if app_exc is not None:
raise app_exc
if request._is_disconnected:
return Response()
raise RuntimeError("No response returned.")

assert message["type"] == "http.response.start"
Expand Down

0 comments on commit cd26b14

Please sign in to comment.