Skip to content

await request.body() or json hangs #5091

@nirradi

Description

@nirradi

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from 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)

Description

Simple request causes this to hang:


from requests import Session

while 1:
    session = Session()
    print("requesting")
    response = session.post(
        'http://docker.for.mac.localhost:8000/dummypath',
        json=list(range(0, 10000)),
        headers={}
    )

this will succeed 4,5 times, and then stop.

Operating System

Linux

Operating System Details

Docker image, python:3.10.4-slim-buster
serving with uvicorn==0.18.2

FastAPI Version

0.78.0

Python Version

Python 3.9.13

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions