Guard socket Redis reads before mutating room state#6
Open
mzl2233 wants to merge 1 commit into
Open
Conversation
AnupamKumar-1
requested changes
May 14, 2026
AnupamKumar-1
left a comment
Owner
There was a problem hiding this comment.
Thanks for the PR — I tested this locally and found a semantic regression here.
getState() returning null does not always mean Redis failure. For fresh rooms it can also mean “uninitialized/missing key”.
Right now the new guard treats all null values as Redis failure, which causes healthy fresh-room joins to fail even when Redis is working.
Could you revisit the detection logic so it distinguishes:
- actual Redis failure
vs - valid empty/uninitialized state?
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.
This adds explicit guards around Redis-backed room state reads before mutating participant or state data. Join now aborts with a socket error when Redis state cannot be read, leave and metadata updates stop instead of writing over uncertain state, and participant broadcasts are skipped when the participants read fails. Existing behavior is unchanged when Redis returns valid empty state.\n\nTested with:\n- node --check src/services/socket.service.js\n- node --check src/controllers/socket.controller.js\n\nCloses #5