Stream timeout error kind/message is confusing
Summary
If a stream times out, the error message seems to imply it's an ExitTimeout
, but the kind()
is not ExitTimeout
.
What is the expected behavior?
// arti_client 0.10.2
use arti_client::config::TorClientConfigBuilder;
use arti_client::HasKind;
use arti_client::TorClient;
#[tokio::main]
async fn main() -> arti_client::Result<()> {
let mut builder = TorClientConfigBuilder::default();
builder
.stream_timeouts()
.connect_timeout(std::time::Duration::from_micros(10));
let tor_client = TorClient::create_bootstrapped(builder.build().unwrap()).await?;
let connection = tor_client.connect(("example.com", 80)).await;
if let Err(e) = connection {
println!("Error: {e} - {e:?}");
println!("Error kind(): {}", e.kind());
println!(
"Is ExitTimeout? {}",
matches!(e.kind(), arti_client::ErrorKind::ExitTimeout)
);
}
Ok(())
}
Output:
Error: tor: operation timed out at exit: Timed out while waiting for answer from exit - Error { detail: ExitTimeout }
Error kind(): operation timed out at exit
Is ExitTimeout? false
The error messages all seem to indicate that it's an ExitTimeout
, but the actual kind is RemoteNetworkTimeout
. What makes it more confusing is that ExitTimeout
is an actual kind. So if you see the above error message and then try to match on the error with something like Err(e) if e.kind() == ExitTimeout
, it will compile but you won't actually catch the error properly.
Edited by opara