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
While messing around with a simple Real-Time app, I encountered the following issue:
Issue Summary:
When the socket receives the disconnecting event, it fails to properly notify the associated rooms about the disconnection due to the usage of the incompatible for..in loop (no iteration is performed).
Currently, within the codebase, there exists a situation where the socket.rooms object, defined as a Set<string>, is being iterated using a for..in loop. However, for..in loops aren't compatible with Sets, potentially causing unexpected behavior or errors.
Due to this problem, the server fails to emit the expected room-user-change event.
Proposed Solution:
Refactor the iteration of socket.rooms to use for..of, forEach, or any loop mechanism compatible with Set<string> to ensure proper iteration and avoid potential issues related to incompatible iteration methods.
Additional Information:
$ npm -v
9.8.1
$ node -v
v18.18.2
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
While messing around with a simple Real-Time app, I encountered the following issue:
Issue Summary:
When the socket receives the
disconnecting
event, it fails to properly notify the associated rooms about the disconnection due to the usage of the incompatiblefor..in
loop (no iteration is performed).Currently, within the codebase, there exists a situation where the
socket.rooms
object, defined as aSet<string>
, is being iterated using afor..in
loop. However, for..in loops aren't compatible withSets
, potentially causing unexpected behavior or errors.Due to this problem, the server fails to emit the expected
room-user-change
event.Proposed Solution:
Refactor the iteration of
socket.rooms
to usefor..of
,forEach
, or any loop mechanism compatible withSet<string>
to ensure proper iteration and avoid potential issues related to incompatible iteration methods.Additional Information:
Links
MDN For..in
MDN For..of
Socket.io | socket.rooms
Codebase
The text was updated successfully, but these errors were encountered: