Skip to content

Commit 79b7cef

Browse files
authored
fix(identify): don't close stream in protocol::recv
Don't close the stream `protocol::recv`. This is a short-term fix for #3298. The issue behind this is a general one on the QUIC transport when closing streams, as described in #3343. This PR only circumvents the issue for identify. A proper solution for our QUIC transport still needs more thought. Pull-Request: #3344.
1 parent 0f4930f commit 79b7cef

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

protocols/identify/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
- Update to `libp2p-swarm` `v0.42.0`.
99

10+
- Don't close the stream when reading the identify info in `protocol::recv`. See [PR 3344].
11+
1012
[PR 3208]: https://github.com/libp2p/rust-libp2p/pull/3208
13+
[PR 3344]: https://github.com/libp2p/rust-libp2p/pull/3344
1114

1215
# 0.41.1
1316

protocols/identify/src/protocol.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,14 @@ where
189189
Ok(())
190190
}
191191

192-
async fn recv<T>(mut socket: T) -> Result<Info, UpgradeError>
192+
async fn recv<T>(socket: T) -> Result<Info, UpgradeError>
193193
where
194194
T: AsyncRead + AsyncWrite + Unpin,
195195
{
196-
socket.close().await?;
196+
// Even though we won't write to the stream anymore we don't close it here.
197+
// The reason for this is that the `close` call on some transport's require the
198+
// remote's ACK, but it could be that the remote already dropped the stream
199+
// after finishing their write.
197200

198201
let info = FramedRead::new(
199202
socket,

0 commit comments

Comments
 (0)