diff --git a/apollo-coroutines-support/src/main/kotlin/com/apollographql/apollo/coroutines/CoroutinesExtensions.kt b/apollo-coroutines-support/src/main/kotlin/com/apollographql/apollo/coroutines/CoroutinesExtensions.kt index 73da2b37c72..9d8fb3012e1 100644 --- a/apollo-coroutines-support/src/main/kotlin/com/apollographql/apollo/coroutines/CoroutinesExtensions.kt +++ b/apollo-coroutines-support/src/main/kotlin/com/apollographql/apollo/coroutines/CoroutinesExtensions.kt @@ -13,9 +13,8 @@ import kotlinx.coroutines.flow.* private class ChannelCallback(val channel: Channel>) : ApolloCall.Callback() { - @ExperimentalCoroutinesApi override fun onResponse(response: Response) { - if (!channel.isClosedForSend) { + runCatching { channel.offer(response) } } @@ -196,7 +195,9 @@ fun ApolloSubscriptionCall.toChannel(capacity: Int = Channel.UNLIMITED): } override fun onResponse(response: Response) { - channel.offer(response) + runCatching { + channel.offer(response) + } } override fun onFailure(e: ApolloException) {