Running a FastAPI app with nginx unit and getting a Starlette error #2448
Unanswered
bunny-therapist
asked this question in
Q&A
Replies: 2 comments
-
This error goes away if I go back to starlette 0.27.0, where the code where the error is coming from does not exist: 554b9e2 |
Beta Was this translation helpful? Give feedback.
0 replies
-
An issue has been created on nginx unit and there I have commented exactly which commit(s) introduced this problem: nginx/unit#1104 I have no idea if it is nginx unit or starlette which is at fault here. I do not see these errors with uvicorn, which suggests it is unit. However, it is hard for me to judge. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
am running a FastAPI app using nginx unit, and using a python script to send multiple sequential (wait for response before sending next) requests to it with the "requests" library. When I reuse the same
requests.Session
object for all the requests, so thatrequests.Session.close
is not called, then I get intermittent crashes in the application and thus status 500 back.The error is coming from this line: https://github.com/encode/starlette/blob/master/starlette/middleware/base.py#L56
which appears to be starlette waiting for a client disconnect but instead getting the next request. (No idea why starlette wants the request to be closed instead of allowing it to be reused for the next request, but maybe there is something I am not aware of.)
I did not encounter this issue when running my FastAPI app with uvicorn, it only happens with nginx unit, but the error is still coming from inside starlette and I cannot understand why this is happening. I have already posted the same question to nginx unit: nginx/unit#1100
Beta Was this translation helpful? Give feedback.
All reactions