Skip to content

Guard socket Redis reads before mutating room state#6

Open
mzl2233 wants to merge 1 commit into
AnupamKumar-1:mainfrom
mzl2233:fix/redis-read-null-guards
Open

Guard socket Redis reads before mutating room state#6
mzl2233 wants to merge 1 commit into
AnupamKumar-1:mainfrom
mzl2233:fix/redis-read-null-guards

Conversation

@mzl2233

@mzl2233 mzl2233 commented May 14, 2026

Copy link
Copy Markdown

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

@AnupamKumar-1 AnupamKumar-1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

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.

2 participants