libp2p / libp2p/rust-libp2p

Should a `NetworkBehavior` be informed about a dropped `ToSwarm::NotifyHandler` event?

Open
#5,718 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

Description

Behaviors can send events to a connection handler by emitting a ToSwarm::NotifyHandler event.
Depending on the PendingNotifyHandler::{One(_), Any(_)} parameter, the swarm will then select either one specific, or any connection handler, that will receive the event.

If the connection has closed in the mean time (either the one specific that is targeted, or all connections), the event gets silently discarded.

@jxs and I had a brief out-of-band discussion that we might want to inform the behavior about the event being dropped.

However, thinking about it now, I am not sure if the behavior even needs that info.
As already mentioned, the event is only dropped if the connection closed. The behavior is being informed about connections closing. So behaviors like request-response can simply track pending events for each connection, and based on that infer that a pending event/ request is discarded.
That must be done anyway because it could be that the handler already consumed the event and then the connection closes.

@jxs is there a specific case where it's still problematic that the NotifyHandler event is silently dropped? And if so, how does that differ from the second scenario that I described, where the connection closes after the handler consumed the event?

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 tracing NetworkBehavior handling of ToSwarm::NotifyHandler and PendingNotifyHandler::{One, Any} through connection-close processing. Compare dropped events with events consumed before a connection closes, using the existing behavior and handler lifecycle paths mentioned in the issue. Done requires a decided outcome for whether behaviors receive notification and an agreed implementation scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.