Seemingly random error `RuntimeError: No Reponse returned.`
See original GitHub issue- Related discussion: https://github.com/encode/starlette/discussions/1527
Same error though I don’t know if cause is the same, we have not been able to reproduce the error in our environments.
The issue
Our frontend is getting HTTP 500 errors from our FastAPI backend. The error is shown below. The error is seemingly random, we have not been able to reproduce it. The traceback does not lead anywhere to our own source code. It has happened on multiple different endpoint requests. We have wrapped our endpoint code in try/except
blocks to catch any “hidden” error in our code to trigger this, but it did not catch anything, leading me to believe that this is an underlying error in the framework.
We discovered the error on FastAPI v0.71.0 (Starlette v0.17.1). We tried upgrading FastAPI to v0.76.0 (Starlette v0.18.0), the error became more frequent. We have now downgraded FastAPI to v0.68.2 hoping that the error dissipates.
python v3.8 uvicorn v0.15.0
INFO: xxx - "POST /api/xxx HTTP/1.1" 500
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/xxx/venv/lib64/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 375, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/xxx/venv/lib64/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "/xxx/venv/lib64/python3.8/site-packages/fastapi/applications.py", line 208, in __call__
await super().__call__(scope, receive, send)
File "/xxx/venv/lib64/python3.8/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/xxx/venv/lib64/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc
File "/xxx/venv/lib64/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "/xxx/venv/lib64/python3.8/site-packages/starlette/middleware/base.py", line 63, in __call__
response = await self.dispatch_func(request, call_next)
File "/xxx/venv/lib64/python3.8/site-packages/prometheus_fastapi_instrumentator/instrumentation.py", line 172, in dispatch_middleware
raise e from None
File "/xxx/venv/lib64/python3.8/site-packages/prometheus_fastapi_instrumentator/instrumentation.py", line 169, in dispatch_middleware
response = await call_next(request)
File "/xxx/venv/lib64/python3.8/site-packages/starlette/middleware/base.py", line 45, in call_next
raise RuntimeError("No response returned.")
RuntimeError: No Reponse returned.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
We solved the GZipMiddleware issue a couple of days ago. You can look for my PRs, it’s one of the latest merged. It will be available on the next release - the issue was on the
BaseHTTPMiddleware
.I’m away from the computer for some days, so I’ll not be able to help. What I can say is that the
BaseHTTPMiddleware
has more issues, which we are aware, but there shouldn’t be any regression on the latest versions related to that piece of code.There are not that many issues, and PRs, you can see the issues it has.
EDIT: This was the fix for
GZipMiddleware
: https://github.com/encode/starlette/pull/1609/ .Some adjustments to the reproduced issue to give exception from original description, solutions (from my previous post) are still the same.
Edit: It would be nice to know what throws the exception, but i don’t know how to catch it,
try/except
inredis_dependency
does not catch anything