await request.body() or json hangs #8534
-
First Check
Commit to Help
Example Codefrom fastapi import FastAPI, Request
from fastapi import APIRouter
router = APIRouter(tags=['tag'])
@router.post("/dummypath")
async def get_body(request: Request):
return await request.body()
app = FastAPI(
title='Service',
version='0.1.0',
)
app.include_router(router)DescriptionSimple request causes this to hang: this will succeed 4,5 times, and then stop. Operating SystemLinux Operating System DetailsDocker image, python:3.10.4-slim-buster FastAPI Version0.78.0 Python VersionPython 3.9.13 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 1 reply
-
|
this seems to be only happening on docker for mac, could be a very specific networking issue. |
Beta Was this translation helpful? Give feedback.
-
|
Hitting this issue as well - both in Docker for Mac - as well as during a CI/CD check in github - so not sure if it's just Docker for Mac |
Beta Was this translation helpful? Give feedback.
-
|
Just had this issue just on mac. |
Beta Was this translation helpful? Give feedback.
-
|
Having this issue on windows 10 with py310 - poetry env. |
Beta Was this translation helpful? Give feedback.
-
|
Potentially a real issue. |
Beta Was this translation helpful? Give feedback.
-
|
Issue is with Starlette actually. Looks like they are yet to find a good approach for exposing the body of the request. |
Beta Was this translation helpful? Give feedback.
-
|
any known workaround while waiting for the starlette to be fixed ? |
Beta Was this translation helpful? Give feedback.
-
|
Just pumping it up :) ! |
Beta Was this translation helpful? Give feedback.
-
|
Currently facing this issue as well. My middleware can parse the request body fine but when it hits the endpoint handler function the request body hangs with trying request.body() and request.json() |
Beta Was this translation helpful? Give feedback.
-
|
I'm also facing same issue on Mac OS with docker container. I know that there are some issues with starlette, so most of case (#394 (comment)) workaround @RORO-ML mentioned works fine. For me, this approach helped. |
Beta Was this translation helpful? Give feedback.
-
|
The same issue is happening for me with Windows 11 WSL docker container. I have tried all the work arounds and nothing seems to work. Most of the threads are about middleware, but I have no middleware and simply want to |
Beta Was this translation helpful? Give feedback.
-
|
Fixed in Starlette 0.28 |
Beta Was this translation helpful? Give feedback.
Fixed in Starlette 0.28