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

ApolloParseException is wrapping SocketException, StreamResetException #5757

Closed
erintenhulzen opened this issue Mar 22, 2024 · 3 comments
Closed

Comments

@erintenhulzen
Copy link

Version

3.8*

Summary

I have a multi-module application, where some modules are leveraging 2* while some are leveraging 3*. In modules which have migrated from 2* to 3*, there is an uptick in ApolloParseExceptions. The underlying causes look to be:

  1. java.net.SocketException: Connection reset
  2. okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL
  3. java.net.SocketException: Software caused connection abort

Feature code integration and error handling is "same" between 2* and 3*.

Steps to reproduce the behavior

Additional context: a single exception handler treatment of errors between 2.* and 3.* exists to ensure exception treatment is consistent.

  • com.apollographql.apollo.exception.ApolloHttpException and com.apollographql.apollo3.exception.ApolloHttpException
  • com.apollographql.apollo.exception.ApolloNetworkException and - com.apollographql.apollo3.exception.ApolloNetworkException
  • com.apollographql.apollo.exception.ApolloParseException and com.apollographql.apollo3.exception.ApolloParseException
  • etc

For ApolloParseException, SocketTimeoutException (#2783) is explicitly handled in both 2.* and 3.* cases.

However, the reported exceptions do not appear in ApolloParseException in 2.*.

Logs

SocketException - connection reset
com.apollographql.apollo3.exception.ApolloParseException: Failed to parse GraphQL http network response
	at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.com.apollographql.apollo3.network.http.HttpNetworkTransport$Companion.wrapThrowableIfNeeded(Unknown Source:376)
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport$Companion.access$wrapThrowableIfNeeded
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport.singleResponse
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport.access$singleResponse
                                                                          invokeSuspend
	at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.invoke(Unknown Source:12)
                                                                          invoke
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Unknown Source:2)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Unknown Source:69)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(Unknown Source:2)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperator.kotlinx.coroutines.flow.internal.ChannelFlowOperator.collect$suspendImpl(Unknown Source:21)
                                                         collect
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ReduceKt.single(Unknown Source:68)
                                   single
	at com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.invokeSuspend(Unknown Source:79)
	at com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.invoke(Unknown Source:12)
                                                                                    invoke
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Unknown Source:2)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Unknown Source:69)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect(Unknown Source:9)
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ErrorsKt.catchImpl(Unknown Source:67)
                                   catchImpl
	at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(Unknown Source:71)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect(Unknown Source:9)
	at kotlinx.coroutines.flow.FlowKt__EmittersKt$onCompletion$$inlined$unsafeFlow$1.collect(Unknown Source:93)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(Unknown Source:2)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperator.kotlinx.coroutines.flow.internal.ChannelFlowOperator.collect$suspendImpl(Unknown Source:21)
                                                         collect
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ReduceKt.single(Unknown Source:68)
                                   single
	at com.apollographql.apollo3.ApolloCall.execute(Unknown Source:310)
...
Caused by: java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(SocketInputStream.java:191)
	at java.net.SocketInputStream.read(SocketInputStream.java:143)
	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readFromSocket(ConscryptEngineSocket.java:983)
	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.processDataFromSocket(ConscryptEngineSocket.java:947)
	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readUntilDataAvailable(ConscryptEngineSocket.java:862)
	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.read(ConscryptEngineSocket.java:835)
	at okio.InputStreamSource.read(Unknown Source:40)
	at okio.AsyncTimeout$source$1.read(Unknown Source:7)
	at okio.RealBufferedSource.request(Unknown Source:30)
	at okio.RealBufferedSource.require(Unknown Source:0)
	at okhttp3.internal.http2.Http2Reader.nextFrame(Unknown Source:5)
	at okhttp3.internal.http2.Http2Connection$ReaderRunnable.okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Unknown Source:11)
                                                          invoke
	at okhttp3.internal.concurrent.TaskQueue$execute$1.runOnce(Unknown Source:2)
	at okhttp3.internal.concurrent.TaskRunner.okhttp3.internal.concurrent.TaskRunner.runTask(Unknown Source:18)
                                           access$runTask
	at okhttp3.internal.concurrent.TaskRunner$runnable$1.run(Unknown Source:43)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)
SocketException - connection abort
com.apollographql.apollo3.exception.ApolloParseException: Failed to parse GraphQL http network response
	at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.com.apollographql.apollo3.network.http.HttpNetworkTransport$Companion.wrapThrowableIfNeeded(Unknown Source:376)
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport$Companion.access$wrapThrowableIfNeeded
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport.singleResponse
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport.access$singleResponse
                                                                          invokeSuspend
	at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.invoke(Unknown Source:12)
                                                                          invoke
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Unknown Source:2)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Unknown Source:69)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(Unknown Source:2)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperator.kotlinx.coroutines.flow.internal.ChannelFlowOperator.collect$suspendImpl(Unknown Source:21)
                                                         collect
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ReduceKt.single(Unknown Source:68)
                                   single
	at com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.invokeSuspend(Unknown Source:79)
	at com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.invoke(Unknown Source:12)
                                                                                    invoke
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Unknown Source:2)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Unknown Source:69)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect(Unknown Source:9)
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ErrorsKt.catchImpl(Unknown Source:67)
                                   catchImpl
	at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(Unknown Source:71)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect(Unknown Source:9)
	at kotlinx.coroutines.flow.FlowKt__EmittersKt$onCompletion$$inlined$unsafeFlow$1.collect(Unknown Source:93)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(Unknown Source:2)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperator.kotlinx.coroutines.flow.internal.ChannelFlowOperator.collect$suspendImpl(Unknown Source:21)
                                                         collect
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ReduceKt.single(Unknown Source:68)
                                   single
	at com.apollographql.apollo3.ApolloCall.execute(Unknown Source:310)
...
Caused by: java.net.SocketException: Software caused connection abort
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:118)
	at java.net.SocketInputStream.read(SocketInputStream.java:173)
	at java.net.SocketInputStream.read(SocketInputStream.java:143)
	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readFromSocket(ConscryptEngineSocket.java:945)
	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.processDataFromSocket(ConscryptEngineSocket.java:909)
	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readUntilDataAvailable(ConscryptEngineSocket.java:824)
	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.read(ConscryptEngineSocket.java:797)
	at okio.InputStreamSource.read(Unknown Source:40)
	at okio.AsyncTimeout$source$1.read(Unknown Source:7)
	at okio.RealBufferedSource.request(Unknown Source:30)
	at okio.RealBufferedSource.require(Unknown Source:0)
	at okhttp3.internal.http2.Http2Reader.nextFrame(Unknown Source:5)
	at okhttp3.internal.http2.Http2Connection$ReaderRunnable.okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Unknown Source:11)
                                                          invoke
	at okhttp3.internal.concurrent.TaskQueue$execute$1.runOnce(Unknown Source:2)
	at okhttp3.internal.concurrent.TaskRunner.okhttp3.internal.concurrent.TaskRunner.runTask(Unknown Source:18)
                                           access$runTask
	at okhttp3.internal.concurrent.TaskRunner$runnable$1.run(Unknown Source:43)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
	at java.lang.Thread.run(Thread.java:1012)
StreamResetException
com.apollographql.apollo3.exception.ApolloParseException: Failed to parse GraphQL http network response
	at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.com.apollographql.apollo3.network.http.HttpNetworkTransport$Companion.wrapThrowableIfNeeded(Unknown Source:376)
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport$Companion.access$wrapThrowableIfNeeded
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport.singleResponse
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport.access$singleResponse
                                                                          invokeSuspend
	at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.invoke(Unknown Source:12)
                                                                          invoke
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Unknown Source:2)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Unknown Source:69)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(Unknown Source:2)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperator.kotlinx.coroutines.flow.internal.ChannelFlowOperator.collect$suspendImpl(Unknown Source:21)
                                                         collect
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ReduceKt.single(Unknown Source:68)
                                   single
	at com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.invokeSuspend(Unknown Source:79)
	at com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.com.apollographql.apollo3.interceptor.AutoPersistedQueryInterceptor$intercept$1.invoke(Unknown Source:12)
                                                                                    invoke
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Unknown Source:2)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Unknown Source:69)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect(Unknown Source:9)
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ErrorsKt.catchImpl(Unknown Source:67)
                                   catchImpl
	at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(Unknown Source:71)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect(Unknown Source:9)
	at kotlinx.coroutines.flow.FlowKt__EmittersKt$onCompletion$$inlined$unsafeFlow$1.collect(Unknown Source:93)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(Unknown Source:2)
	at kotlinx.coroutines.flow.internal.ChannelFlowOperator.kotlinx.coroutines.flow.internal.ChannelFlowOperator.collect$suspendImpl(Unknown Source:21)
                                                         collect
	at kotlinx.coroutines.flow.FlowKt.kotlinx.coroutines.flow.FlowKt__ReduceKt.single(Unknown Source:68)
                                   single
	at com.apollographql.apollo3.ApolloCall.execute(Unknown Source:310)
...
Caused by: okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL
	at okhttp3.internal.http2.Http2Stream$FramingSource.read(Unknown Source:42)
	at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Unknown Source:10)
	at okio.RealBufferedSource.read(Unknown Source:29)
	at okio.RealBufferedSource.exhausted(Unknown Source:18)
	at okio.InflaterSource.okio.InflaterSource.refill(Unknown Source:45)
                        readOrInflate
	at okio.InflaterSource.read(Unknown Source:0)
                        read
                        read
	at okio.GzipSource.read(Unknown Source:293)
	at okio.RealBufferedSource.okio.RealBufferedSource.indexOfElement(Unknown Source:27)
                            indexOfElement
	at com.apollographql.apollo3.api.json.BufferedSourceJsonReader.nextQuotedValue(Unknown Source:3)
	at com.apollographql.apollo3.api.json.BufferedSourceJsonReader.nextString(Unknown Source:95)
	at com.apollographql.apollo3.api.json.-JsonReaders.readAny(Unknown Source:95)
	at com.apollographql.apollo3.api.json.-JsonReaders.readAny(Unknown Source:83)
	at com.apollographql.apollo3.api.json.-JsonReaders.readAny(Unknown Source:83)
	at com.apollographql.apollo3.api.json.MapJsonReader$Companion.buffer(Unknown Source:24)
	at com.apollographql.apollo3.api.ObjectAdapter.fromJson(Unknown Source:6)
	at com.apollographql.apollo3.api.ObjectAdapter.fromJson(Unknown Source:15)
	at com.apollographql.apollo3.api.NullableAdapter.fromJson(Unknown Source:15)
	at com.apollographql.apollo3.api.internal.ResponseParser.parse(Unknown Source:54)
	at com.apollographql.apollo3.api.Operations.parseJsonResponse(SourceFile:11)
	at com.apollographql.apollo3.network.http.HttpNetworkTransport$execute$1.com.apollographql.apollo3.network.http.HttpNetworkTransport.singleResponse(Unknown Source:326)
                                                                          com.apollographql.apollo3.network.http.HttpNetworkTransport.access$singleResponse
                                                                          invokeSuspend
@martinbonnin
Copy link
Contributor

Hi @erintenhulzen Apologies for the delay.

I took a quick look in #5816, let me know what you think!

@martinbonnin
Copy link
Contributor

I'll close this for now. 4.x has:

  • ApolloNetworkException for IO errors.
  • JsonEncodingException for bad JSON encoding.
  • JsonDataException for bad JSON data (bad types).

Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Kotlin usage and allow us to serve you better.

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

No branches or pull requests

3 participants