Skip to content

fix: add socket reconnection backoff and clean up leaked listeners#263

Open
Flegma wants to merge 1 commit intomainfrom
audit/386-listener-cleanup
Open

fix: add socket reconnection backoff and clean up leaked listeners#263
Flegma wants to merge 1 commit intomainfrom
audit/386-listener-cleanup

Conversation

@Flegma
Copy link
Copy Markdown
Contributor

@Flegma Flegma commented Apr 8, 2026

Summary

  • Socket.ts: Replace fixed 1-second reconnect with exponential backoff (1s→30s) with jitter, max 50 retries. Clean up old WebSocket on reconnect to prevent listener accumulation.
  • ChatLobby.vue: Stop previous lobbyListener before creating new one in lobbyId watcher
  • MatchmakingConfirm.vue: Clear existing interval before creating new countdown, fix beforeUnmount null check

Closes 5stackgg/5stack-panel#386, 5stackgg/5stack-panel#387

Test plan

  • Verify WebSocket reconnects with increasing delays when server is unavailable
  • Verify reconnection resets to 1s delay after successful connection
  • Verify switching chat lobbies doesn't accumulate listeners
  • Verify matchmaking countdown works correctly on rapid confirmation changes

Replace fixed 1-second reconnect delay with exponential backoff
(1s-30s) with jitter and a 50-attempt max. Clean up old WebSocket
before reconnecting. Stop previous lobbyListener in ChatLobby
watcher. Guard interval creation in MatchmakingConfirm.
@lukepolo
Copy link
Copy Markdown
Contributor

lukepolo commented Apr 9, 2026

why have a max?

@Flegma Flegma requested a review from lukepolo April 10, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Web] Socket listeners & component event handlers never cleaned up

2 participants