fix: run one moss node per process, not per conversation - #39
Merged
Conversation
0.7.3 consolidated DMs onto a single node; public channels, private groups and orgs each still started their own. Node identity is per process, so a client in three channels and two groups announced one peer id from six ports — a remote peer keeps one session per identity, closes the rest on arrival and declines to dial the others. Channels, groups and orgs now join a room on the shared node (SharedMossNode holds it, refcounted; the last release stops moss). Every publish is room-scoped, and closing a conversation unsubscribes and leaves its room, which dropping a per-conversation node used to do. Also fixes accept_invite publishing its first KeyPackage room-less, i.e. into the shared node's substrate room instead of the invite's. Wire-compatible: a joined room is byte-identical to the same room owned outright, so 0.7.4 still talks to 0.7.3 and 0.7.2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
0.7.3 put every DM on one moss node. Public channels, private groups and orgs
each still started their own. Node identity is per process, so a client sitting
in three channels and two groups announced one peer id from six ports — the
exact pattern 0.7.3 measured: a remote peer keeps one session per identity,
closes the rest on arrival, and declines to dial the others because it already
holds that id.
Channels, groups and orgs now join a room on the same node the DMs use. A whole
client is one node, one port.
How
mosh-core/src/shared_node.rs:SharedMossNodeowns the process's node,refcounted —
acquirestarts it on first demand, the lastreleasestops it.Born in
mosh-dm/1, the room DM nodes have used since 0.7.3, so the substratea released client sees does not move.
src-tauri/src/lib.rshands the SAME holder to all four runtimes.join_room+subscribe_roomon open,publish_roomon every send,
unsubscribe_room+leave_room+releaseon close.from_sharedstill mints a private holder, so tests running two peers in oneprocess keep two nodes.
Wire-compatible: a joined room is byte-identical to the same room owned
outright, so 0.7.4 still talks to 0.7.3 and 0.7.2.
Also fixed
conversation, dropping the node ended them. On a shared node it has to be said
out loud.
accept_invitepublished it room-less, which since 0.7.3 means the shared node's substrate
room rather than the invite's. The handshake only recovered because the drain
loop re-publishes it correctly until the Welcome arrives.
Tests
cargo test -p mosh-core: 190 passed, 0 failed, 5 ignored (real moss.dll).New, mirroring the existing DM test:
channels_share_one_node_and_leave_releases_itgroups_share_one_node_and_close_releases_itEach asserts one node pointer across two conversations, distinct
mesh_ids, andthat the node survives the first close but not the last.
Manual check after release
Open two DMs, two public channels and a group — Diagnostics must show the same
Listen port for all of them. A different port anywhere means a room-less publish
survived; it will show as
MOSS_ERR_NOT_IN_ROOM (-14)in the log rather thansilently lost messages.
Not in this PR
The relay node keeps its own node (own mesh, own callbacks, own send worker).
That is one extra port under the same identity, not N.