Fix reconnecting dialog refreshing page repeatedly#61
Merged
JoshuaAFerguson merged 1 commit intoNov 17, 2025
Merged
Conversation
Fixed critical issue where WebSocket reconnection logic created a rapid reconnection loop, making the UI appear to "refresh every second" and become completely unusable. Changes: - Fixed dependency loop in useWebSocket hook by using ref for reconnect attempts - Removed reconnectAttempts from connect() callback dependencies - Improved countdown timer in EnhancedWebSocketStatus to be more efficient - Made reconnect banner dismissal persistent across reconnection attempts - Reduced notification spam when banner is dismissed Root cause: The connect() callback depended on reconnectAttempts state, which changed on every reconnection attempt. This triggered the useEffect to close and immediately reconnect, creating a loop. Testing: Code review confirmed proper use of refs to break dependency cycle. The reconnection logic now only triggers on genuine WebSocket close events, not on state changes.
JoshuaAFerguson
pushed a commit
that referenced
this pull request
Nov 17, 2025
The WebSocket reconnection dialog was causing an infinite reconnection loop that made the UI unusable. This was happening because: 1. WebSocket callback functions were being recreated on every render 2. When callbacks changed, the WebSocket hooks saw them as new dependencies 3. This triggered WebSocket disconnection and reconnection 4. State updates from reconnection triggered component re-renders 5. Back to step 1, creating an infinite loop Fixed by: - Using useRef to store WebSocket callbacks in both useWebSocket and useEnterpriseWebSocket hooks - Updating refs when callbacks change instead of recreating connections - Wrapping callbacks in useCallback in Dashboard, SessionViewer, and SharedSessions pages (defense in depth) - Removing callback dependencies from WebSocket connect() functions This ensures that callback changes don't trigger reconnection, breaking the loop and making the UI stable again. Fixes reconnection issues from PRs #60 and #61.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed critical issue where WebSocket reconnection logic created a rapid reconnection loop, making the UI appear to "refresh every second" and become completely unusable.
Changes:
Root cause: The connect() callback depended on reconnectAttempts state, which changed on every reconnection attempt. This triggered the useEffect to close and immediately reconnect, creating a loop.
Testing: Code review confirmed proper use of refs to break dependency cycle. The reconnection logic now only triggers on genuine WebSocket close events, not on state changes.