-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client
does not disconnect from relays upon Drop
#137
Comments
I tried to implement For now the only way to completely shutdown the client is to exit from the app (the threads will drop) or by calling the |
An alternative to |
Just something to kill the connections on drop would be nice, have run into the problem multiple times on accident |
Maybe you can wrap the pub struct CustomClient {
inner: Client
}
impl Drop for CustomClient {
fn drop(&mut self) {
let client = self.clone();
async_utility::thread::spawn(async move {
client.shutdown().await.unwrap();
});
}
} I can't implement the let client = self.clone();
thread::spawn(async move {
// use client and then drop
}); the client shutdown everywhere. |
Otherwise, I'll try to add a new filed in |
That sounds good |
Done So, init the Client in this way: // ...
let opts = Options::new().shutdown_on_drop(true);
let client = Client::with_opts(&keys, opts);
// ... |
When a
Client
is dropped it still persists the connections to the relays, this is an easy footgun that can cause resource exhaustion.The user needs to remember to call
disconnect()
otherwise.The text was updated successfully, but these errors were encountered: