diff --git a/fastapi/applications.py b/fastapi/applications.py index 9324ea33f..915f5f70a 100644 --- a/fastapi/applications.py +++ b/fastapi/applications.py @@ -1019,10 +1019,8 @@ class FastAPI(Starlette): # streaming responses while keeping compatibility with the previous # versions (as of writing 0.117.1) that allowed doing # except HTTPException inside a dependency with yield. - # This needs to happen after user middlewares because those create a # new contextvars context copy by using a new AnyIO task group. - # This AsyncExitStack preserves the context for contextvars, not # strictly necessary for closing files but it was one of the original # intentions. @@ -1030,7 +1028,6 @@ class FastAPI(Starlette): # contextvars were set, for example in a dependency with 'yield' # in that internal contextvars context, the values would not be # available in the outer context of the AsyncExitStack. - # By placing the middleware and the AsyncExitStack here, inside all # user middlewares, the same context is used. # This is currently not needed, only for closing files, but used to be