Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SentryApolloInterceptor implements ApolloInterceptor but crashes app #3661

Closed
DroidPulkit opened this issue Aug 27, 2024 · 5 comments
Closed

Comments

@DroidPulkit
Copy link

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]
@markushi
Copy link
Member

@DroidPulkit it looks like Apollo v4 introduced a change which breaks our interceptor. By any chance, did you try with Apollo v3 as well?

@kahest
Copy link
Member

kahest commented Aug 28, 2024

Created an issue for implementing Apollo4 support: #3662

@markushi
Copy link
Member

Closing in favor of #3662

@markushi markushi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
@DroidPulkit
Copy link
Author

@DroidPulkit it looks like Apollo v4 introduced a change which breaks our interceptor. By any chance, did you try with Apollo v3 as well?

Yeah for Apollo v3, I was using sentry-apollo3 library, I presumed, that when apollo changed their package name from apollo3 to apollo, after v4 upgrade, you folks at sentry did too. That's the reason, I choose, the sentry-apollo library.
But, now it all makes sense, that we don't have support for apollo v4 yet. Looking forward to it. Thanks

@kahest
Copy link
Member

kahest commented Aug 29, 2024

@DroidPulkit thanks for the input, I agree it's a bit confusing atm - we updated the docs on our Apollo/Apollo3 integrations to clarify which Apollo versions they support, and we'll likely (need to) introduce a new Apollo4 integration later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

No branches or pull requests

3 participants