Skip to content

Commit 85e5d0f

Browse files
authored
fix(rendezvous): log instead of panic when sending response to client
Log error instead of panicking when sending response to channel fails Related: #5997 Pull-Request: #6002.
1 parent 2dc453b commit 85e5d0f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

protocols/rendezvous/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## 0.16.1
1+
## 0.16.1
22
- Emit `ToSwarm::NewExternalAddrOfPeer` for newly discovered peers.
33
See [PR 5138](https://github.com/libp2p/rust-libp2p/pull/5138).
4+
- Log error instead of panicking when sending response to channel fails
5+
See [PR 6002](https://github.com/libp2p/rust-libp2p/pull/6002).
46

57
## 0.16.0
68

protocols/rendezvous/src/server.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,12 @@ impl NetworkBehaviour for Behaviour {
189189
handle_request(peer_id, request, &mut self.registrations)
190190
{
191191
if let Some(resp) = response {
192-
self.inner
193-
.send_response(channel, resp)
194-
.expect("Send response");
192+
if let Err(resp) = self.inner.send_response(channel, resp) {
193+
tracing::debug!(
194+
%peer_id,
195+
"Failed to send response, peer disconnected {resp:?}"
196+
);
197+
}
195198
}
196199

197200
return Poll::Ready(ToSwarm::GenerateEvent(event));

0 commit comments

Comments
 (0)