channels icon indicating copy to clipboard operation
channels copied to clipboard

Ensure text message exists before handling on `WebsocketConsumer`

Open cacoos opened this issue 1 year ago • 0 comments

When using uvicorn or daphne, only one of text or bytes is sent.

But on hypercorn, both of them are sent, but with None value: https://github.com/pgjones/hypercorn/blob/31639ec2f4d03aa920b95c84686163901224c6cf/src/hypercorn/protocol/ws_stream.py#L159

So if you just send bytes, text will be None and you won't be able to handle the message.

I just add an extra check.

cacoos avatar May 02 '24 01:05 cacoos