Skip to content

backend: Potential infinite loops #21

@mxpph

Description

@mxpph

Most of the functions that are run within the WebSocket endpoint, for example, do not have any timeout or expiry. Particularly in #20 we have:

async def wait_pubsub_subscribe(channel: str, subs: int):
    """Wait for subs number of players to subscribe to channel"""
    while True:
        if (await redis_client.pubsub_numsub(channel))[0][1] >= subs:
            return
        await asyncio.sleep(0.01)

which may cause an infinite loop if a client disconnects between receving the start message from the host and subscribing to the game:{game_id}:channel channel as the pubsub_numsub would then never equal subs.

We could probably use some sort of asyncio.timeout() to deal with that (if not, rewriting the whole backend to be more fault-tolerant would also be a solution 😅)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions