Skip to content

Commit

Permalink
Re-enqueue message when outbound stream fails
Browse files Browse the repository at this point in the history
An outbound stream carries the first message for the remote node when upgrading in the
`OutboundOpenInfo`. Thus far the GossipSub handler would drop the message when the outbound stream
fails to upgrade.

This could e.g. lead to a remote peer receiving a GRAFT without a previous SUBSCRIBE.

With this commit the message carried in the upgrade's `OutboundOpenInfo` is re-enqueued.
  • Loading branch information
mxinden committed Mar 29, 2023
1 parent 0507493 commit b572895
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion protocols/gossipsub/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,12 @@ impl ConnectionHandler for Handler {
}
ConnectionEvent::DialUpgradeError(DialUpgradeError {
error: ConnectionHandlerUpgrErr::Timeout | ConnectionHandlerUpgrErr::Timer,
..
info,
}) => {
log::debug!("Dial upgrade error: Protocol negotiation timeout.");

// Re-enqueue message.
self.send_queue.insert(0, info);
}
ConnectionEvent::DialUpgradeError(DialUpgradeError {
error: ConnectionHandlerUpgrErr::Upgrade(UpgradeError::Apply(e)),
Expand Down

0 comments on commit b572895

Please sign in to comment.