Skip to content

Commit

Permalink
fix(hole-punch): don't explicitly close RESERVE stream
Browse files Browse the repository at this point in the history
Making a reservation on a relay involves a request-response protocol. First we send the `RESERVE` message and then we receive the relay's response. After we've received the response, we have all the information we need and the reservation is valid.

It appears that on QUIC, closing the stream can fail if the other party also closed the stream already. This can result in the entire operation failing at the very end even though everything else has succeeded.

There is no reason to explicitly close the stream as the remote is not going to read from it beyond the first message anyway. The fact that we receive a response means the remote read our request.

This should resolve some of the flakiness that we've been seeing with the hole-punch interop tests.

Pull-Request: #4747.
  • Loading branch information
thomaseizinger authored Oct 27, 2023
1 parent 3118503 commit 461209a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 3 additions & 0 deletions protocols/relay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 0.17.0 - unreleased

- Fix a rare race condition when making a reservation on a relay that could lead to a failed reservation.
See [PR 4747](https://github.com/libp2p/rust-lib2pp/pulls/4747).

## 0.16.2

## 0.16.1
Expand Down
2 changes: 0 additions & 2 deletions protocols/relay/src/protocol/outbound_hop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ pub(crate) async fn handle_reserve_message_response(
.map(Delay::new)
.ok_or(FatalUpgradeError::InvalidReservationExpiration)?;

substream.close().await?;

Ok(Ok(Reservation {
renewal_timeout,
addrs,
Expand Down

0 comments on commit 461209a

Please sign in to comment.