Skip to content

Commit 89531c1

Browse files
vnermolaevtcoratger
authored andcommitted
fix(gossipsub): gracefully disable handler on stream errors
Previously, we closed the entire connection upon receiving too many upgrade errors. This is unnecessarily aggressive. For example, an upgrade error may be caused by the remote dropping a stream during the initial handshake which is completely isolated from other protocols running on the same connection. Instead of closing the connection, set `KeepAlive::No`. Related: libp2p#3591. Resolves: libp2p#3690. Pull-Request: libp2p#3625.
1 parent fc44e0a commit 89531c1

File tree

11 files changed

+301
-278
lines changed

11 files changed

+301
-278
lines changed

Cargo.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocols/gossipsub/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
- Fix erroneously duplicate message IDs. See [PR 3716].
1010

11+
- Gracefully disable handler on stream errors. Deprecate a few variants of `HandlerError`.
12+
See [PR 3625].
13+
1114
[PR 3716]: https://github.com/libp2p/rust-libp2p/pull/3716
15+
[PR 3625]: https://github.com/libp2p/rust-libp2p/pull/3325
1216

1317
## 0.44.2
1418

protocols/gossipsub/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
1111
categories = ["network-programming", "asynchronous"]
1212

1313
[dependencies]
14-
libp2p-swarm = { version = "0.42.1", path = "../../swarm" }
14+
either = "1.5"
15+
libp2p-swarm = { version = "0.42.2", path = "../../swarm" }
1516
libp2p-core = { version = "0.39.0", path = "../../core" }
1617
libp2p-identity = { version = "0.1.2", path = "../../identity" }
1718
bytes = "1.4"
@@ -33,6 +34,7 @@ serde = { version = "1", optional = true, features = ["derive"] }
3334
thiserror = "1.0"
3435
wasm-timer = "0.2.5"
3536
instant = "0.1.11"
37+
void = "1.0.2"
3638
# Metrics dependencies
3739
prometheus-client = "0.19.0"
3840

protocols/gossipsub/src/error.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ pub type PublishError = crate::error_priv::PublishError;
3030
)]
3131
pub type SubscriptionError = crate::error_priv::SubscriptionError;
3232

33-
#[deprecated(
34-
since = "0.44.0",
35-
note = "Use re-exports that omit `Gossipsub` prefix, i.e. `libp2p::gossipsub::HandlerError"
36-
)]
33+
#[deprecated(note = "This error will no longer be emitted")]
3734
pub type GossipsubHandlerError = crate::error_priv::HandlerError;
3835

39-
#[deprecated(
40-
since = "0.44.0",
41-
note = "Use `libp2p::gossipsub::HandlerError` instead, as the `error` module will become crate-private in the future."
42-
)]
36+
#[deprecated(note = "This error will no longer be emitted")]
4337
pub type HandlerError = crate::error_priv::HandlerError;
4438

4539
#[deprecated(

protocols/gossipsub/src/error_priv.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ impl std::fmt::Display for ValidationError {
134134

135135
impl std::error::Error for ValidationError {}
136136

137-
impl From<std::io::Error> for HandlerError {
138-
fn from(error: std::io::Error) -> HandlerError {
139-
HandlerError::Codec(quick_protobuf_codec::Error::from(error))
140-
}
141-
}
142-
143137
impl From<std::io::Error> for PublishError {
144138
fn from(error: std::io::Error) -> PublishError {
145139
PublishError::TransformFailed(error)

0 commit comments

Comments
 (0)