Skip to content

fix(autorelay): look for a new relay after a failed reservation refresh - #3554

Open
Shailu-s wants to merge 1 commit into
libp2p:masterfrom
Shailu-s:fix-autorelay-refresh-failure-reconnect
Open

Shailu-s wants to merge 1 commit into
libp2p:masterfrom
Shailu-s:fix-autorelay-refresh-failure-reconnect

Conversation

@Shailu-s

@Shailu-s Shailu-s commented Oct 7, 2026

Copy link
Copy Markdown

When a reservation refresh fails (e.g. the relay disabled its relay service, which keeps connections open, or refused for resource limits), refreshRelayReservation drops the relay but never triggers maybeConnectToRelay. The disconnect path in cleanupDisconnectedPeers does the same delete but also calls notifyMaybeConnectToRelay() and notifyMaybeNeedNewCandidates().

Since findNodes doesn't poll the peer source while len(candidates) >= minCandidates, the remaining candidates sit unused and the node can stay below desiredRelays (possibly with no relay addrs) until clearOldCandidates expires them, 30 min by default.

This notifies after removing a relay we were using, mirroring the disconnect path.

TestConnectOnRefreshFailure is modelled on TestConnectOnDisconnect: the relay in use stays connected but stops serving the hop protocol, so the next refresh fails. It fails on master (no replacement is ever picked) and passes with the fix. go test -race ./p2p/host/autorelay/... passes.

When a reservation refresh fails, refreshRelayReservation drops the relay but,
unlike the disconnect path, never triggers maybeConnectToRelay. Remaining
candidates sit unused and the node can stay below the desired number of
relays until the candidates expire (30 min by default).

Notify the relay finder after removing a relay we were using, the same way
the disconnect path does.
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.

1 participant