-
-
Notifications
You must be signed in to change notification settings - Fork 104
fix: realtime late join #6869
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
base: main
Are you sure you want to change the base?
fix: realtime late join #6869
Conversation
This is still WIP? This only adds tests. |
Found out that somehow the wrong iroh topic is transmitted to fiona and that is why she fails to join. In every send invocation a new topic is generated, and we use resend... |
fa9afd2
to
ed12f9a
Compare
@link2xt I made some unrelated changes, which are easy to track in the individual commits, but they pollute the final PR. Would you prefer to split this into a refactor and bug-fix PR? |
If it's just these documentation updates then no need to split this. |
1c471ed
to
2d12aec
Compare
It seems like the test is a bit flaky (for me it ran 7/8 times), but I do not know a fix of the top of my head yet.. Maybe we can just check how often it actually happens and fix it if neccessary in a follow up PR |
@@ -1492,7 +1499,7 @@ impl MimeFactory { | |||
} | |||
SystemMessage::IrohNodeAddr => { | |||
headers.push(( | |||
"Iroh-Node-Addr", | |||
HeaderDef::IrohNodeAddr.into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.get_headername()
would read more straightforwardly (and we use it in many other places). But probably we should just rename HeaderDef
to HeaderName
, the current naming looks unclear.
@@ -109,7 +109,7 @@ impl Iroh { | |||
|
|||
info!( | |||
ctx, | |||
"IROH_REALTIME: Joining gossip with peers: {:?}", node_ids, | |||
"IROH_REALTIME: Joining gossip {topic} with peers: {:?}", node_ids, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"IROH_REALTIME: Joining gossip {topic} with peers: {:?}", node_ids, | |
"IROH_REALTIME: Joining gossip {topic} with peers: {:?}.", node_ids, |
@@ -198,7 +192,7 @@ impl Iroh { | |||
} | |||
|
|||
/// Leave the realtime channel for a given topic. | |||
pub(crate) async fn leave_realtime(&self, topic: TopicId) -> Result<()> { | |||
pub async fn leave_realtime(&self, topic: TopicId) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it needs to be public now?
if let Some(iroh) = &*self.iroh.read().await { | ||
info!( | ||
self, | ||
"Adding (maybe existing) peer with id {} to {topic}", peer.node_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Adding (maybe existing) peer with id {} to {topic}", peer.node_id | |
"Adding (maybe existing) peer with id {} to {topic}.", peer.node_id |
} | ||
|
||
/// Cache a peers [NodeId] for one topic. | ||
pub(crate) async fn iroh_add_peer_for_topic( | ||
pub async fn iroh_add_peer_for_topic( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same question
@@ -336,6 +341,7 @@ pub(crate) async fn iroh_add_peer_for_topic( | |||
} | |||
|
|||
/// Add gossip peer from `Iroh-Node-Addr` header to WebXDC message identified by `instance_id`. | |||
/// This should not start iroh, because receiving a NodeAddr does not mean you want to participate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// This should not start iroh, because receiving a NodeAddr does not mean you want to participate. | |
/// This does not start Iroh, because receiving a NodeAddr does not mean you want to participate. |
Also, why is this public?
Ok(()) | ||
} | ||
|
||
/// Insert topicId into the database so that we can use it to retrieve the topic. | ||
pub(crate) async fn insert_topic_stub(ctx: &Context, msg_id: MsgId, topic: TopicId) -> Result<()> { | ||
pub async fn insert_topic_stub(ctx: &Context, msg_id: MsgId, topic: TopicId) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same question
let msg = alice.pop_sent_msg().await; | ||
let fiona_instance = fiona.recv_msg(&msg).await; | ||
fiona_instance.chat_id.accept(fiona).await.unwrap(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a check that peer channels aren't initialized, otherwise the test would pass w/o the fix
async fn connect_alice_bob( | ||
alice: &mut TestContext, | ||
bob: &mut TestContext, | ||
chat: ChatId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be clear that it's Alice's ChatId, renaming it or reordering parameters would make sense
This PR adds a test to reproduce a bug raised by @adbenitez that peer channels break when the resend feature is used.