Skip to content

[network] connection_events() is a placeholder that never yields #119

@intendednull

Description

@intendednull

Parent: #108

Problem

crates/network/src/iroh.rs:345-349:

async fn connection_events(&self) -> ConnectionEventStream {
    // Placeholder: return a stream that never yields.
    // Full implementation would monitor endpoint relay and direct connection state.
    Box::pin(futures_lite::stream::pending())
}

crates/network/src/mem.rs:378-381 has the same pending stream.

Anything awaiting connection_events() hangs forever. Callers assume they've subscribed to relay/peer connect/disconnect events — they haven't.

Fix

Two options:

Option A: implement it properly. Hook into iroh's underlying connection-state events and emit ConnectionEvent::RelayUp, RelayDown, PeerConnected, PeerDisconnected. For MemNetwork, emit synthetic events when MemHub subscribes/unsubscribes a peer. This is the right long-term answer.

Option B: delete the method and update the trait. If no in-tree caller actually uses the stream (grep for connection_events across crates), just remove the trait method and each impl. Add a TODO(#TBD) if we expect to need it later.

Start by doing a workspace-wide grep for connection_events callers. If there are any, option A. If not, option B.

Test

If implementing: a MemNetwork test that subscribes two peers, connects one via the hub, and asserts a PeerConnected event is emitted within a bounded time.

If deleting: just make sure nothing breaks and document the rationale in the commit message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions