fix: Reduce Drift SDK auto-reconnect interval from 4h to 2h
Problem: Bot froze after only 1 hour of runtime with API timeouts, despite having 4-hour auto-reconnect protection for Drift SDK memory leak. Investigation showed: - Singleton pattern working correctly (reusing same instance) - Hundreds of accountUnsubscribe errors (WebSocket leak) - Container froze at ~1 hour, not 4 hours Root Cause: Drift SDK's memory leak is MORE SEVERE than expected. Even with single instance, subscriptions accumulate faster than anticipated. 4-hour interval too long - system hits memory/connection limits before cleanup. Solution: Reduce auto-reconnect interval to 2 hours (more aggressive). This ensures cleanup happens before critical thresholds reached. Code change (lib/drift/client.ts): - reconnectIntervalMs: 4 hours → 2 hours - Updated log messages to reflect new interval Impact: System now self-heals every 2 hours instead of 4, preventing the freeze that occurred tonight at 1-hour mark. Related: Common Pitfall #1 (Drift SDK memory leak)
This commit is contained in:
@@ -31,7 +31,7 @@ export class DriftService {
|
||||
private user: User | null = null
|
||||
private isInitialized: boolean = false
|
||||
private reconnectTimer: NodeJS.Timeout | null = null
|
||||
private reconnectIntervalMs: number = 4 * 60 * 60 * 1000 // 4 hours (prevent memory leak)
|
||||
private reconnectIntervalMs: number = 2 * 60 * 60 * 1000 // 2 hours (aggressive - Drift SDK memory leak is severe)
|
||||
|
||||
constructor(private config: DriftConfig) {
|
||||
// Helius connection for Drift SDK initialization (handles burst subscriptions well)
|
||||
@@ -200,7 +200,7 @@ export class DriftService {
|
||||
clearTimeout(this.reconnectTimer)
|
||||
}
|
||||
|
||||
// Schedule reconnection every 4 hours
|
||||
// Schedule reconnection every 2 hours
|
||||
this.reconnectTimer = setTimeout(async () => {
|
||||
try {
|
||||
console.log('🔄 Scheduled reconnection: Clearing WebSocket subscriptions to prevent memory leak...')
|
||||
|
||||
Reference in New Issue
Block a user