Skip to content

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

fix: realtime late join #6869

wants to merge 14 commits into from

Conversation

Septias
Copy link
Collaborator

@Septias Septias commented May 21, 2025

This PR adds a test to reproduce a bug raised by @adbenitez that peer channels break when the resend feature is used.

@WofWca
Copy link
Collaborator

WofWca commented May 22, 2025

This is still WIP? This only adds tests.

@Septias Septias marked this pull request as draft May 23, 2025 07:57
@Septias
Copy link
Collaborator Author

Septias commented Jul 7, 2025

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...

@Septias Septias force-pushed the sk/test_webxdc_resend branch 2 times, most recently from fa9afd2 to ed12f9a Compare July 8, 2025 08:24
@Septias
Copy link
Collaborator Author

Septias commented Jul 8, 2025

@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?

@Septias Septias marked this pull request as ready for review July 8, 2025 12:39
@link2xt
Copy link
Collaborator

link2xt commented Jul 9, 2025

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.

@Septias Septias force-pushed the sk/test_webxdc_resend branch from 1c471ed to 2d12aec Compare July 10, 2025 07:58
@Septias
Copy link
Collaborator Author

Septias commented Jul 10, 2025

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

@Septias Septias requested review from link2xt and iequidoo July 14, 2025 10:03
@@ -1492,7 +1499,7 @@ impl MimeFactory {
}
SystemMessage::IrohNodeAddr => {
headers.push((
"Iroh-Node-Addr",
HeaderDef::IrohNodeAddr.into(),
Copy link
Collaborator

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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<()> {
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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(
Copy link
Collaborator

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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<()> {
Copy link
Collaborator

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();

Copy link
Collaborator

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,
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants