Fixes suspending on coroutineScope and never returning bug

This commit is contained in:
Vitor Pamplona
2025-10-02 16:39:20 -04:00
parent 47cc8fc4ae
commit 132c00d434
@@ -91,6 +91,7 @@ suspend fun INostrClient.sendAndWaitForResponse(
// subscribe before sending the result.
val resultSubscription =
coroutineScope {
val result =
async(Dispatchers.IO) {
val receivedResults = mutableMapOf<NormalizedRelayUrl, Boolean>()
// The withTimeout block will cancel the coroutine if the loop takes too long
@@ -107,10 +108,12 @@ suspend fun INostrClient.sendAndWaitForResponse(
}
receivedResults
}
}
send(event, relayList)
result
}
val receivedResults = resultSubscription.await()
unsubscribe(subscription)