Skip to content

SentryApolloInterceptor implements ApolloInterceptor but crashes app #3661

Closed as not planned
@DroidPulkit

Description

@DroidPulkit

Integration

sentry-android

Build System

Gradle

AGP Version

8.5.0

Proguard

Enabled

Version

7.14.0

Steps to Reproduce

  1. Use Apollo GraphQL version: 4.0.0 and com.apollographql.apollo:apollo-runtime library
  2. Use Sentry latest version and use sentry-apollo library
  3. Add SentryApolloInterceptor to your ApolloClient.Builder() with .addInterceptor(SentryApolloInterceptor())
  4. Run the app to emulator

Expected Result

App should run, right?

Actual Result

App crashes why?

SentryApolloInterceptor implements ApolloInterceptor.
What is ApolloInterceptor?

interface ApolloInterceptor {
  fun <D : Operation.Data> intercept(request: ApolloRequest<D>, chain: ApolloInterceptorChain): Flow<ApolloResponse<D>>
}

We have override fun interceptAsync() instead of override fun intercept() in SentryApolloInterceptor class, which leads to following crash:

java.lang.AbstractMethodError: abstract method "kotlinx.coroutines.flow.Flow com.apollographql.apollo.interceptor.ApolloInterceptor.intercept(com.apollographql.apollo.api.ApolloRequest, com.apollographql.apollo.interceptor.ApolloInterceptorChain)"
                            	at com.apollographql.apollo.interceptor.DefaultInterceptorChain.proceed(ApolloInterceptor.kt:23)
                            	at com.apollographql.apollo.ApolloClient.apolloResponses$apollo_runtime_debug(ApolloClient.kt:322)
                            	at com.apollographql.apollo.ApolloClient$executeAsFlowInternal$flow$1$2.invokeSuspend(ApolloClient.kt:260)
                            	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                            	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                            	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
                            	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
                            	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
                            	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
                            	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
                            	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)
                            	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3b7b1dc, Dispatchers.Main.immediate]

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions