Skip to content

Commit c82460b

Browse files
committed
do not broadcast event to all clients if modify state is misused
1 parent f9b0d4d commit c82460b

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
@@ -1996,6 +1996,10 @@ async def emit_update(self, update: StateUpdate, sid: str) -> None:
19961996
update: The state update to send.
19971997
sid: The Socket.IO session id.
19981998
"""
1999+
if not sid:
2000+
# If the sid is None, we are not connected to a client. Prevent sending
2001+
# updates to all clients.
2002+
return
19992003
# Creating a task prevents the update from being blocked behind other coroutines.
20002004
await asyncio.create_task(
20012005
self.emit(str(constants.SocketEvent.EVENT), update, to=sid)

0 commit comments

Comments
 (0)