Skip to content

Commit a30096d

Browse files
committed
Disconnect existing session when associating new session
When an event is received that will associate a client token with a new sid, disconnect the previous sid, since it will no longer be used.
1 parent b0ddceb commit a30096d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

reflex/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,10 @@ async def on_event(self, sid: str, data: Any):
19031903
f"Failed to deserialize event data: {fields}."
19041904
) from ex
19051905

1906+
old_sid = self.token_to_sid.get(event.token)
1907+
if old_sid and old_sid != sid:
1908+
console.debug(f"Token {event.token} transferring from {old_sid} to {sid}.")
1909+
await self.disconnect(old_sid)
19061910
self.token_to_sid[event.token] = sid
19071911
self.sid_to_token[sid] = event.token
19081912

0 commit comments

Comments
 (0)