ASUCICREPO / waterbot

MIT License
0 stars 2 forks source link

Eventual Memory Leak from MemoryManager / SessionMiddleware #6

Open dhe-cr opened 5 months ago

dhe-cr commented 5 months ago

Both MemoryManager and SessionManager house data. This will grow infinitely as currently there is no logic to clear stale sessions.

Implement code to tie a session expiration date to the session and delete out stale sessions from SessionManager & MemoryManager.

dhe-cr commented 5 months ago

Possible Approaches:

1) Perhaps through websocket ? on websocket disconnect cleanup initiated. 2)

    session_uuid = request.cookies.get(COOKIE_NAME)
    if session.get("message_count") is None:
        session["message_count"] = 0
        await memory.create_session(session_uuid)

We can potentially tie cookie session id to the other session middleware. have a periodic cleanup process that checks session expiration and then eliminates.

dhe-cr commented 5 months ago

Note, need to address behavior of user clicks out, comes back prior to session expiration and then hits session expiration. (receive new cookie) -- probably want to force a new session?

perhaps on landing on index always force a new session. (doesn't alleviate user leaving window open for 2 hours)

dhe-cr commented 5 months ago

perhaps "easy" mode could be against date . initiate api endpoint called cleanup and it clears out memory beyond that date.