Skip to content

Commit 45f417e

Browse files
committed
catch offer exceptions. See Kotlin/kotlinx.coroutines#974
1 parent 533a163 commit 45f417e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apollo-coroutines-support/src/main/kotlin/com/apollographql/apollo/coroutines/CoroutinesExtensions.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import kotlinx.coroutines.flow.*
1313

1414
private class ChannelCallback<T>(val channel: Channel<Response<T>>) : ApolloCall.Callback<T>() {
1515

16-
@ExperimentalCoroutinesApi
1716
override fun onResponse(response: Response<T>) {
18-
if (!channel.isClosedForSend) {
17+
runCatching {
1918
channel.offer(response)
2019
}
2120
}
@@ -196,7 +195,9 @@ fun <T> ApolloSubscriptionCall<T>.toChannel(capacity: Int = Channel.UNLIMITED):
196195
}
197196

198197
override fun onResponse(response: Response<T>) {
199-
channel.offer(response)
198+
runCatching {
199+
channel.offer(response)
200+
}
200201
}
201202

202203
override fun onFailure(e: ApolloException) {

0 commit comments

Comments
 (0)