You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor redisReceiver to eliminate global state and prevent memory leaks
This commit completely refactors the redisReceiver module to eliminate all
module-level global state and move to request-scoped encapsulation.
Changes:
- Remove global sharedRedisClient, activeListeners, and pendingPromises
- Create private Redis client per listenToRequestData() call
- Move pendingPromises to per-listener scope for complete request isolation
- Remove listener caching mechanism (no reuse via activeListeners)
- Fix race condition bug in connection logic using connectionPromise tracking
- Always close Redis client in close() method (no conditional logic)
- Use delete instead of setting to undefined for proper memory cleanup
Benefits:
- Complete request isolation - no shared state between concurrent requests
- Eliminates memory leaks from accumulating undefined map entries
- Prevents race condition where multiple concurrent connection attempts fail
- Simpler code without global state management complexity
- Better resource management with guaranteed cleanup
External API unchanged - no breaking changes to consumers.
Fixes#1893
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments