Has anyone looked into the memory leak in the dashboard service? Production metrics show a steady climb.
I noticed that too. The heap snapshot shows a lot of unreleased event listeners on the WebSocket connection.
Makes sense. We added the real-time dashboard updates last sprint. The cleanup function might be missing in the useEffect.
I can confirm — I checked the WebSocket hook and there's no return cleanup. Each re-render opens a new connection without closing the old one.
That explains the connection count we're seeing. Node process has over 2,000 open WebSocket connections per pod.
I'll fix the hook now. Should be straightforward — just need to return ws.close() from the effect and add the dependency array.
Can you also add connection pooling? We should reuse connections across components instead of creating new ones for each dashboard widget.
Good idea. I'll create a WebSocket provider at the app level so all dashboard components share a single connection.
That's the right approach. Make sure to handle reconnection logic in the provider too — exponential backoff with jitter.
Once the fix is deployed, I'll monitor the memory metrics for 24 hours to confirm the leak is resolved. The dashboard should stabilize around 200MB per pod.
PR is up: #1847. Added the cleanup, connection pooling provider, and reconnection with backoff. Ready for review.
Reviewing now. Looks clean. One suggestion — add a max reconnection attempt limit so it doesn't retry forever if the server is down.