-
-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Bug Description
In useRemoteConnection.ts , the WebSocket is stored using useState. The useEffect cleanup function captures the initial state value (null), so when the component unmounts, ws?.close() does nothing so it never references the actual socket.
This means the socket stays open, and any pending reconnect timers continue firing even after the component is gone, creating zombie connections.
Proposed Solution:
Replace useState with useRef for the WebSocket instance, A ref is always up to date, so cleanup can reliably close the real socket. Add an isMounted flag to block reconnection after unmount, and remove ws from the trackpad.tsx sendCombo dependency arrays since refs don't need them.
Steps to Reproduce
- Open the Trackpad page (WebSocket connects)
- Stop the dev server to trigger a disconnect
- While the 3-second reconnect timer is pending, navigate away from the page
- Restart the server, orphaned "Client connected" logs appear from zombie sockets
Expected Behavior
The WebSocket should be properly closed on unmount, and no reconnection attempts should happen after the component is gone.
Desktop Operating System
Windows 11
Mobile Device (Client)
Samsung Galaxy A56
Rein Version
No response
Console Logs / Error Messages
Screenshots / Recordings
No response
Checklist
- I have searched for existing issues to avoid duplicates