Skip to content

Issue with new socketsJoin #4734

Description

@dalda95

Migrating from remoteJoin to use the socketsJoin i have notice a strange behavior, seems that the socketsJoin method is not waiting for a response from others server so that if we perform an emit after a socketJoin the added socket is not receiving the message

Notice: the socketId1 maybe is connected to another server


io.in(socketId1).socketsJoin(room1)
io.to(room1).emit('my-event', payload)

in that case the socketId1 is not receiving the message, i saw the code and in the past version the remoteJoin was a Promise so i imagine that the function is waiting for a response, but now i think that is not waiting causing a problem, maybe i miss something, but if i add in the middle a simple fetchSockets it start to work

io.in(socketId1).socketsJoin(room1)
await io.in(room1).fetchSockets() // also sometimes it not return the socketId1
io.to(room1).emit('my-event', payload)

if i add a:

io.in(socketId1).socketsJoin(room1)
io.to(room1).emit('my-event', payload)


setTimeout(async() => {
     await io.in(room1).fetchSockets() // in that case it return always the socketId
}, 1000)

can you please help me to understand the problem here ?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions