join / publish race condition
When a process joins a group and then immediately publishes in that group, the newly joined process doesn't receive the message. For example:
Swarm.join(:test, self())
Swarm.publish(:test, :ping)
# Doesn't receive :ping message
However, when adding a sleep:
Swarm.join(:test, self())
:timer.sleep(500)
Swarm.publish(:test, :ping)
# Does receive :ping message
Even though add_meta uses call it doesn't seem to get registered immediately. The behavior would probably also depend on the host machine being used.
I'm not sure if this is a bug or intended, but I didn't see any mention of this in the readme. Other people might bump into the same issue so I decided to report it. Could you please confirm if this is a bug or not? Thanks
This is because Swarm.publish is reading group memberships directly from ETS, and bypassing the tracker. We'll need to have publish go through the tracker to avoid this issue. I wouldn't classify it as a bug per-se, since it was intentional to avoid the tracker, but I didn't have a use case for the code above, so I was willing to make that tradeoff. It seems better that we make the behaviour intuitive though, so I'll make the change.