Skip to content

Commit

Permalink
Fix potential crash in connection state flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Aug 5, 2024
1 parent 7af6b25 commit a2649ec
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import io.grpc.ConnectivityState
import io.grpc.ManagedChannel
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.cancel
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.isActive
Expand All @@ -20,5 +22,7 @@ internal fun ManagedChannel.connectivityFlow(): Flow<ConnectivityState> {
}
send(currentState)
}

awaitClose { cancel() }
}
}

0 comments on commit a2649ec

Please sign in to comment.