HIGH: Unclosed aiohttp Sessions Cause Resource Leaks #19
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
aiohttp sessions are created but not properly closed, leading to resource leaks and connection exhaustion.
Where It Occurs
Why This Is a Problem
What Can Go Wrong
Scenario 1: Session Exhaustion After Extended Runtime
Scenario 2: WebSocket Connection Pool Full
Proposed Fix
Use async with context managers for all aiohttp sessions. Create APIClient class with session management and close on shutdown.
Severity
HIGH - Unclosed sessions cause resource exhaustion and require bot restart.
Files Affected
bot/utils/voice_audio.py, bot/stt_client.py, cat-plugins/danbooru_client.py, bot/utils/image_generation.py