util: correctly throw channel errors

Wasn't being properly handled before, leading to weird behavior.
This commit is contained in:
Alexander Capehart
2024-01-01 12:02:38 -07:00
parent ed519eeccc
commit 77f0bbe614
@@ -186,7 +186,7 @@ suspend fun <E> ReceiveChannel<E>.forEachWithTimeout(
var subsequent = false
val handler: suspend () -> Unit = {
val value = receiveCatching()
if (value.isClosed) {
if (value.isClosed && value.exceptionOrNull() == null) {
exhausted = true
} else {
action(value.getOrThrow())