fix: auto-reconnect websocket after unexpected close (#18) - #376
Open
slsgzs-cloud wants to merge 1 commit into
Open
slsgzs-cloud wants to merge 1 commit into
slsgzs-cloud wants to merge 1 commit into
Conversation
Author
|
Hi maintainers! This PR is mergeable and clean. It fixes a bounty issue worth $50. Would appreciate a review. |
Author
|
Hi @Rodrigoue9 @leocagli — PR #376 fixes Issue #18 (50 USD bounty). It is mergeable and clean. Could you review when you have a moment? Thank you! |
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.
/attempt #743
Summary
Fixes #18.
The bug
When the websocket dropped,
socket.oncloseonly emitted a "Conexion cerrada."status and never tried again. The player was stranded with a dead connection and
had to reload the page and re-pick a character.
The fix
useGameSessionnow schedules a delayed reconnection whenever the socket closes,driven by a new
reconnectAttemptstate that is a dependency of the connectionuseEffect:RECONNECT_MAX_ATTEMPTS(5) retries, with exponential backoff(1s, 2s, 4s, 8s, 16s).
reconnectAttempt, which re-runs the effect and opens a freshsocket. When the retry budget is exhausted the status stays at
"Conexion cerrada." with no further retry, so a genuinely dead connection
cannot produce a retry storm.
a new game (a different character/account combination) always begins with a
full set of retries.
disconnecting never leaves a stale reconnect scheduled.
isCurrentSocketInstance+activeSessionKeyRefguards), so a stale socketclosing after a session switch cannot trigger a spurious reconnect.
Files changed:
frontend/components/game/session/useGameSession.ts