You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty .to([]) sends to everybody instead of nobody #4645
@Frank3K it is a in-memory adapter, and indeed it should be smth like if (rooms.size !== undefined). However, I have encountered same issue with a redis adapter.
So, it must be fixed in multiple places
UPD: Nevermind, the redis adapter still relies on the in-memory one
@darrachequesne yep, I found out already that no rooms is treated as no specific rooms.
I thought it would be a simple one-line fix, but properly introducing a "broadcast to [] rooms" requires changes across quite a few places of this codebase, which I'm not familiar with tbh
Activity
myYang2016 commentedon Mar 2, 2023
I have this problem too, and I have to check every time to see if it's an empty array
darrachequesne commentedon Mar 3, 2023
@jyustman I could indeed reproduce the behavior, thanks. That is indeed surprising, I guess we can fix this in the next major release.
inimaz commentedon May 9, 2023
I can take a look at this one if that's fine?
Frank3K commentedon Dec 28, 2023
I observed the same. Could it be due to the following condition in socket.io-adapter?
https://github.com/socketio/socket.io-adapter/blob/28f60b880ad04ff4b48ade0cd529f1970643604f/lib/index.ts#L335-L355
drmgc commentedon Mar 20, 2025
@Frank3K it is a in-memory adapter, and indeed it should be smth like
if (rooms.size !== undefined). However, I have encountered same issue with a redis adapter.So, it must be fixed in multiple placesUPD: Nevermind, the redis adapter still relies on the in-memory one
fix(socketio#4645): message emitted to all the rooms, if got `[]` rooms
fix(socket.io-adapter/socketio#4645): message emitted to all the room…
fix(socket.io-adapter/socketio#4645): message emitted to all the room…
darrachequesne commentedon Mar 28, 2025
@drmgc the issue is that there is no distinction between no room and an empty room:
Source:
socket.io/packages/socket.io/lib/broadcast-operator.ts
Lines 20 to 27 in 72d61da
drmgc commentedon Mar 31, 2025
@darrachequesne yep, I found out already that
no roomsis treated asno specific rooms.I thought it would be a simple one-line fix, but properly introducing a "broadcast to [] rooms" requires changes across quite a few places of this codebase, which I'm not familiar with tbh
PrasanthGondi commentedon May 10, 2025
Looks like this hasn't been fixed yet. When can we expect a fix for this?