socketio / socketio/socket.io

Issue with new socketsJoin

Open
#4,734 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two-server scenario described with io.in(socketId1).socketsJoin(room1), followed immediately by io.to(room1).emit('my-event', payload). Compare the behavior with and without io.in(room1).fetchSockets(), and inspect the socketsJoin and fetchSockets entry points. Done means the joined socket reliably receives the subsequent event across servers.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, distributed-systems, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.