Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaving and re-entering a room can cause incorrect room state #17

Closed
dmckeone opened this issue Jan 29, 2016 · 0 comments
Closed

Leaving and re-entering a room can cause incorrect room state #17

dmckeone opened this issue Jan 29, 2016 · 0 comments
Labels

Comments

@dmckeone
Copy link

It seems there is an issue with BaseManager.pending_removals getting stale and causing the removal of a user from a room they should be in.

Example (Imagine the various leave/enter/emit calls being spread out over time and multiple requests):

server = ... # Socket.IO Server
room = 'my room'
session_id = ... # Current session id for one user

# Enter room normally
server.enter_room(session_id, room)  

 # Leave room normally, server.manager.pending_removals populated
server.leave_room(session_id, room) 

# Re-enter room, server.manager.pending_removals still populated
server.enter_room(session_id, room)     

# Message emitted, followed by server.manager.pending_removals being processed internally
server.emit('something', 'data', room=room)     

# Message *NOT* emitted, because the room was removed after the previous emit
server.emit('something else', 'data', room=room)

The workaround was to do:

server = ... # Socket.IO Server
room = 'my room'
session_id = ... # Current session id for one user

# Enter room normally
server.enter_room(session_id, room)  

 # Leave room normally, server.manager.pending_removals populated
server.leave_room(session_id, room) 

# WORKAROUND: Force clean-up of old removals before entering the new room
server.manager._clean_rooms()

# Re-enter room, server.manager.pending_removals is now clear
server.enter_room(session_id, room)     

# Message emitted normally
server.emit('something', 'data', room=room)     

# Message emitted normally
server.emit('something else', 'data', room=room)

This leads me to believe that the fix is likely something that needs to be added to enter_room( ... ) that reconciles the new subscriptions to a given room with the previous, perhaps unreconciled, room evictions in BaseManager.pending_removals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants