From e271fa90d9111c3a1f39492e232efc82afb8a4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Wed, 4 Feb 2026 19:17:47 -0800 Subject: [PATCH] Fix issue that would cause RelayPool to close after ephemeral lease release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue was not released, so a changelog item is not needed. Changelog-None Closes: https://github.com/damus-io/damus/issues/3604 Signed-off-by: Daniel D’Aquino --- damus/Core/Nostr/RelayPool.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/damus/Core/Nostr/RelayPool.swift b/damus/Core/Nostr/RelayPool.swift index 40dcdefe..9171bd1b 100644 --- a/damus/Core/Nostr/RelayPool.swift +++ b/damus/Core/Nostr/RelayPool.swift @@ -414,12 +414,18 @@ class RelayPool { relay.connection.connect() } // Mark as open last, to prevent other classes from pulling data before the relays are actually connected - open = true + // Only mark as open when connecting ALL relays (not specific ones) + if targetRelays == nil { + open = true + } } func disconnect(to targetRelays: [RelayURL]? = nil) async { // Mark as closed first, to prevent other classes from pulling data while the relays are being disconnected - open = false + // Only mark as closed when disconnecting ALL relays (not specific ones) + if targetRelays == nil { + open = false + } let relays = await getRelays(targetRelays: targetRelays) for relay in relays { relay.connection.disconnect()