-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
socket.join could lead to a room leak. #4380
Comments
I could indeed reproduce, thanks 👍 It can also happen within a middleware: io.use((socket, next) => {
socket.join("DUMMY_ROOM");
next(new Error("nope"));
console.log(io.of("/").adapter.rooms); Map(1) { 'DUMMY_ROOM' => Set(1) { 'pqUiVlJ7Q6juccjiAAAB' } }
}); This could explain issues like #4067 Let's fix that. |
darrachequesne
added
bug
Something isn't working
and removed
to triage
Waiting to be triaged by a member of the team
labels
May 25, 2022
OK, so this should be fixed by 18f3fda I think. |
Thanks for to fix it. |
@HsinHeng released. this issue should be closed |
Thanks for your notified. |
dzad
pushed a commit
to dzad/socket.io
that referenced
this issue
May 29, 2023
Calling `socket.join()` after disconnection would lead to a memory leak, because the room was never removed from the memory: ```js io.on("connection", (socket) => { socket.disconnect(); socket.join("room1"); // leak }); ``` Related: - socketio#4067 - socketio#4380
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
We are using socket io since years now, and we discovered a very weird bug that can occur under some conditions.
It seems it's possible to join rooms using the base adapter, even if the socket is destroyed or disconnected. I don't know if it was intended initially, but adapter.addAll shouldn't be connected if the socket is no longer available.
A such issue could appear for instance under an elevated database latency. If the client socket disconnected before the socket.join action, the join action is performed anyway.
To Reproduce
Run those steps 5 times.
DUMMY_ROOM
should have 5 different sockets attached to the rooms, even if those sockets are no longer connected.Please fill the following code example:
Socket.IO server version:
any version
Server
Socket.IO client version:
x.y.z
Client
Expected behavior
socket.join
shouldn't propagatethis.adapter.addAll
if the socket no longer exists.The text was updated successfully, but these errors were encountered: