Skip to content

Commit

Permalink
fix(iroh-net): do not log as error if client disconnects from relay (#…
Browse files Browse the repository at this point in the history
…2259)

## Description

In the relay server, we currently log all connection failures with
`error` severity. This means that whenever a node disconnects while
still in the TLS handshaking phase, we get an error log.:

```
2024-05-02T09:00:38.443215Z ERROR relay server{me=svfacrfjgmv7fjeu}:relay-http-serve:conn{peer=127.0.0.1:33596}: iroh_net::relay::http::server: [HTTPS] relay: failed to handl
e connection: TLS[manual] accept
```

This however is a perfectly fine thing, a node may decide to abort the
connection to a relay whenever it pleases. Especially in tests we often
shutdown while still in the process of connecting to a relay. This is
annoying, because the `error` severity indicates things being wrong
(especially with the stack traces we print on error logs in the CI).

This PR checks if the error is a EOF and if so only prints it as a debug
log.

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
  • Loading branch information
Frando authored May 2, 2024
1 parent 6fbf4a9 commit cdedc43
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions iroh-net/src/relay/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,18 @@ impl ServerState {
let service = self.service.clone();
// spawn a task to handle the connection
set.spawn(async move {
if let Err(e) = service
if let Err(error) = service
.handle_connection(stream, tls_config)
.await
{
error!("[{http_str}] relay: failed to handle connection: {e}");
match error.downcast_ref::<std::io::Error>() {
Some(io_error) if io_error.kind() == std::io::ErrorKind::UnexpectedEof => {
debug!(reason=?error, "[{http_str}] relay: peer disconnected");
},
_ => {
error!(?error, "[{http_str}] relay: failed to handle connection");
}
}
}
}.instrument(info_span!("conn", peer = %peer_addr)));
}
Expand Down

0 comments on commit cdedc43

Please sign in to comment.