Skip to content

FastAPI WebSocket instance differs between handler and Dishka #574

@egorzh01

Description

@egorzh01

When WebSocket is accepted in the handler, the instance provided by dishka remains unaccepted because they are different objects.
At the same time if you try to send a message using the instance provided by Dishka, it will raise an err.

solution is taking dishka websocket instance in handler

@router.websocket("/")
@inject
async def ws(
     _: WebSocket, # hack from #575
    ws: FromDishka[WebSocket],
) -> None:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions