nats.rs icon indicating copy to clipboard operation
nats.rs copied to clipboard

Connect coroutine can't terminate

Open uyugame opened this issue 1 year ago • 1 comments

Make sure that these boxes are checked before submitting your issue -- thank you!

  • [0.24 ] Included below version and environment information
  • [ ] Included a [Minimal, Complete, and Verifiable example] (https://stackoverflow.com/help/mcve)

NATS version (grep 'name = "nats"' Cargo.lock -A 1)

rustc version (rustc --version - we support Rust 1.41 and up)

OS/Container environment:

Steps or code to reproduce the issue:

connect coroutine will leak when retry_on_initial_connect is set and try connect to a wrong address

 pub(crate) async fn connect(&mut self) -> Result<(ServerInfo, Connection), io::Error> {
        loop {
            match self.try_connect().await {
                Ok(inner) => return Ok(inner),
                Err(error) => {
                    self.events_tx
                        .send(Event::ClientError(ClientError::Other(error.to_string())))
                        .await
                        .ok();
                }
            }
        }
    }

Expected result:

get some ways to drop bad Client with wrong server address

Actual result:

if we set a wrong addrees,we can't drop the bad Client.

uyugame avatar Dec 06 '22 05:12 uyugame

Hey,

thanks for the report. https://github.com/nats-io/nats.rs/pull/692 should fix it, and when dropping Client, all tokio::tasks should be dropped too.

Jarema avatar Dec 12 '22 13:12 Jarema