YoEight / eventstore-rs

Rust GetEventStore TCP Client
MIT License
46 stars 20 forks source link

Panic on second call if server is off #52

Closed chapa closed 4 years ago

chapa commented 4 years ago

Hello,

When we try to make requests on a shutdown server, the program panic at the second call. Strangely, the first call works well (returns an Err) but not the second.

Here is an example :

use eventstore::{Connection, Credentials};

#[tokio::main]
async fn main() {
    let connection = Connection::builder()
        .with_default_user(Credentials::new("admin", "changeit"))
        .single_node_connection("127.0.0.1:1113".parse().unwrap())
        .await;

    println!("{:?}", connection.read_all().execute().await);
    println!("{:?}", connection.read_all().execute().await);
}

And the execution output :

Err(Aborted)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Canceled', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/eventstore-0.7.4/src/internal/operations.rs:939:9

I expected to get an Err on each requests, am I misunderstanding something ?

Thank you !

YoEight commented 4 years ago

Hi @chapa and thanks for opening this issue. It's an oversight and shouldn't panic in this case. It should be the user who decides if they want to panic or not.

chapa commented 4 years ago

You're welcome ! I've done some digging and I think I can fix the problem, do you want me to open a PR ?

YoEight commented 4 years ago

Yes, I'd like too.