Closed
Description
Hi!
We use a wrapper around ApolloSubscriptionCall<T>.toChannel
extension and we're having some crashes although we use it inside a CoroutineScope
with an exception handler.
Error:
com.apollographql.apollo.internal.subscription.ApolloSubscriptionTerminatedException:
at com.myapp.extensions.ApolloExtensionsKt$toChannelHandleTerminate$2.onTerminated (ApolloExtensions.kt:39)
at com.apollographql.apollo.internal.RealApolloSubscriptionCall$SubscriptionManagerCallback.onTerminated (RealApolloSubscriptionCall.java:168)
at com.apollographql.apollo.internal.subscription.RealSubscriptionManager.onConnectionClosed (RealSubscriptionManager.java:284)
at com.apollographql.apollo.internal.subscription.RealSubscriptionManager$SubscriptionTransportCallback$4.run (RealSubscriptionManager.java:457)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:764)
After investigation, we found that this is caused by some concurrency issues inside ApolloSubscriptionCall.Callback
.
The method channel.offer(response)
can still be called after the channel has been closed. And since the callback use a separate Thread, the exception isn't caught by the coroutine's exception handler, causing a crash.
Metadata
Metadata
Assignees
Labels
No labels