- Memory leak identified: Drift SDK accumulates WebSocket subscriptions over time - Root cause: accountUnsubscribe errors pile up when connections close/reconnect - Symptom: Heap grows to 4GB+ after 10+ hours, eventual OOM crash - Solution: Automatic reconnection every 4 hours to clear subscriptions Changes: - lib/drift/client.ts: Add reconnectTimer and scheduleReconnection() - lib/drift/client.ts: Implement private reconnect() method - lib/drift/client.ts: Clear timer in disconnect() - app/api/drift/reconnect/route.ts: Manual reconnection endpoint (POST) - app/api/drift/reconnect/route.ts: Reconnection status endpoint (GET) Impact: - Prevents JavaScript heap out of memory crashes - Telegram bot timeouts resolved (was failing due to unresponsive bot) - System will auto-heal every 4 hours instead of requiring manual restart - Emergency manual reconnect available via API if needed Tested: Container restarted successfully, no more WebSocket accumulation expected
2.2 KiB
2.2 KiB