Files
trading_bot_v4/lib/drift
mindesbunister 0cdcd973cd fix(drift): Fix health monitor error interception - CRITICAL BUG
Critical bug fix for automatic restart system:
- Moved interceptWebSocketErrors() call outside retry wrapper
- Now runs once after successful Drift initialization
- Ensures console.error patching works correctly
- Enables health monitor to detect and count errors
- Restores automatic recovery from Drift SDK memory leak

Bug Impact:
- Health monitor was starting but never recording errors
- System accumulated 800+ accountUnsubscribe errors without triggering restart
- Required manual restart intervention (container unhealthy)
- Projection page stuck loading due to API unresponsiveness

Root Cause:
- interceptWebSocketErrors() was called inside retryOperation wrapper
- Retry wrapper executes 0-3 times depending on network conditions
- Console.error patching failed or ran multiple times
- Monitor never received error events

Fix Implementation:
- Added interceptWebSocketErrors() call on line 185 (after Drift init)
- Removed duplicate call from inside retry wrapper
- Added logging: '🔧 Setting up error interception...' and ' Error interception active'
- Error recording now functional

Testing:
- Health API returns errorCount: 0, threshold: 50
- Monitor will trigger restart when 50 errors in 30 seconds
- System now self-healing without manual intervention

Deployment: Nov 25, 2025
Container verified: Error interception active, health monitor operational
2025-11-25 10:19:04 +01:00
..