You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Applications often want to persist data from the lifespan cycle to request/response handling. ... The server will ensure that a shallow copy of the namespace is passed into each subsequent request/response call into the application.
Actual Behavior
When a lifespan startup handler adds content to the scope.state dict, it is correctly stored in the ASGIMiddleware state property, however the state is never used again, it is not added to request.state in subsequent ASGI Requests as expected.
Steps to Reproduce
Create an ASGI App that supports ASGI Lifetime handling (eg, Starlette, or FastAPI)
Create a Lifetime handler, that receives the Scope object
Add some content to the Scope.state dict,
eg, scope.state["message"] = "hello world"
Add a ASGI request handler that receives a request parameter.
Attempt to read request.state["message"] from the request
result = request.state == {} - Empty dict
error index error, "message" not in request.state
Where are you facing this problem?
Local - Core Tools
The text was updated successfully, but these errors were encountered:
Expected Behavior
The ASGI Spec states that contents of the lifespan startup's
scope.state
dict is stored by the ASGI server, and the state is added to any subsequent ASGI Requests.https://asgi.readthedocs.io/en/latest/specs/lifespan.html
Actual Behavior
When a lifespan startup handler adds content to the
scope.state
dict, it is correctly stored in the ASGIMiddlewarestate
property, however the state is never used again, it is not added torequest.state
in subsequent ASGI Requests as expected.Steps to Reproduce
Scope
objectScope.state
dict,scope.state["message"] = "hello world"
request
parameter.request.state["message"]
from the requestrequest.state == {}
- Empty dictindex error, "message" not in request.state
Where are you facing this problem?
Local - Core Tools
The text was updated successfully, but these errors were encountered: