From 9d8a2c9e3f147a6350538b692f086381cc32862d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kyle=20=F0=9F=90=86?= Date: Thu, 16 Jul 2026 12:21:14 -0400 Subject: [PATCH] keep-nip46: disconnect client on connect_with setup-error path --- keep-nip46/src/client.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/keep-nip46/src/client.rs b/keep-nip46/src/client.rs index 57baad45..664ad746 100644 --- a/keep-nip46/src/client.rs +++ b/keep-nip46/src/client.rs @@ -233,7 +233,13 @@ impl Nip46Client { match tokio::time::timeout(DEFAULT_REQUEST_TIMEOUT, setup).await { Ok(Ok(())) => {} - Ok(Err(e)) => return Err(e), + Ok(Err(e)) => { + // Disconnect before propagating so the relay connections and the + // nostr-sdk background tasks they spawn are torn down instead of + // leaking (Drop does not disconnect), matching the timeout arm. + client.disconnect().await; + return Err(e); + } Err(_) => { client.disconnect().await; return Err(NetworkError::timeout(