From a15fe94e2f41cdbe38b98d339f268aae122308b4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 18 Jun 2026 13:37:15 +0000 Subject: [PATCH] debug(relay): log connected-set vs pool cache after updatePool The background teardown works (desired collapses to 11, toRemove=349) but the persistent notification still reports ~110 connected relays. That points at the _connectedRelays StateFlow (what the notification reads) being decoupled from the pool's desired set: it is only decremented from the async onFailure/onClosed websocket callback, while disconnect() uses OkHttp cancel() (immediate/violent). Add a post-reconcile log comparing cacheConnected (relays still in the pool reporting isConnected) against flowConnected (_connectedRelays.size) to confirm whether the 110 are live sockets or a stale count. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01Ukw6FJPFh3JKGXL532p3ae --- .../quartz/nip01Core/relay/client/pool/RelayPool.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/RelayPool.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/RelayPool.kt index 854e45e80d..f1b4f673c6 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/RelayPool.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/pool/RelayPool.kt @@ -175,6 +175,7 @@ class RelayPool( if (atLeastOne) { _availableRelays.update { relays.keys() } } + Log.d("BgRelayTrace") { "updatePool done — cacheConnected=${connectedRelaysCount()}, flowConnected=${_connectedRelays.value.size}, inPool=${relays.size()}" } } fun addRelay(relay: NormalizedRelayUrl): IRelayClient {