aiohttp icon indicating copy to clipboard operation
aiohttp copied to clipboard

EofStream and websocket.receive_* functions

Open socketpair opened this issue 2 years ago • 0 comments

aiohttp 3.8.1

await websocket.receive_json() Will die with TypeError on WSMsgType.CLOSED.

#2784 is fixed, yes:

 async def __anext__(self) -> WSMessage:
        msg = await self.receive()
        if msg.type in (WSMsgType.CLOSE, WSMsgType.CLOSING, WSMsgType.CLOSED):
            raise StopAsyncIteration
        return msg

Yes, bug is fixed in iterator but NOT fixed for websocket.receive_* functions, like receive_json()

I would raise RuntimeError or so if corresponding message "type" (like bytes, str, or json) can not be received.

socketpair avatar Jun 22 '22 09:06 socketpair