Skip to content

Commit eb0d6f2

Browse files
authored
req-resp: Fix panic on connection closed for substream open failure (#291)
When a new connection is reported to the request-response protocol, the protocol tracks the state of the connection if and only if it could open a substream with the remote peer. We do not track the state of the connection in cases where the substream cannot be opened because the connection is closed. A further `ConnectionClosed` event triggered a debug_assert assumption for this case. The assumption is wrong since opening substreams can fail which informs us that the connection is closed. Connection details not tracked: https://github.com/paritytech/litep2p/blob/eed0f755d591eb49e1b715a78aceb5a653ddf529/src/protocol/request_response/mod.rs#L267-L284 Which later leads to panics: https://github.com/paritytech/litep2p/blob/d6fae559fbe2aaf8cb3fff021fb5608ca7b43766/src/protocol/request_response/mod.rs#L295-L301 Related to: #290 --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
1 parent d6fae55 commit eb0d6f2

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

src/protocol/request_response/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,8 @@ impl RequestResponseProtocol {
296296
tracing::error!(
297297
target: LOG_TARGET,
298298
?peer,
299-
"state mismatch: peer doesn't exist",
299+
"Peer does not exist or substream open failed during connection establishment",
300300
);
301-
debug_assert!(false);
302301
return;
303302
};
304303

src/protocol/request_response/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ async fn connection_closed_twice() {
9292

9393
#[tokio::test]
9494
#[cfg(debug_assertions)]
95-
#[should_panic]
9695
async fn connection_established_twice() {
9796
let (mut protocol, _handle, _manager, _tx) = protocol();
9897

0 commit comments

Comments
 (0)