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

Fatal Exception in Http2Stream$FramingSource.read (DataStore / GraphQL) #2860

Open
1 task done
JornR94 opened this issue Jun 28, 2024 · 2 comments
Open
1 task done
Labels
bug Something isn't working datastore DataStore category/plugins

Comments

@JornR94
Copy link

JornR94 commented Jun 28, 2024

Before opening, please confirm:

Language and Async Model

Java

Amplify Categories

GraphQL API, DataStore

Gradle script dependencies

    implementation 'com.amplifyframework:aws-api:2.16.1'
    implementation 'com.amplifyframework:aws-datastore:2.16.1'

Environment information

------------------------------------------------------------
Gradle 8.0
------------------------------------------------------------

Build time:   2023-02-13 13:15:21 UTC
Revision:     62ab9b7c7f884426cf79fbedcf07658b2dbe9e97

Kotlin:       1.8.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.6 (JetBrains s.r.o. 17.0.6+0-b2043.56-10027231)
OS:           Windows 10 10.0 amd64

Please include any relevant guides or documentation you're referencing

No response

Describe the bug

In our production app, I'm seeing a crash happen occasionally with the Amplify AWS SDK for Android. The crash is a Fatal Exception from io.reactivex.rxjava3.plugins.RxJavaPlugins.onError. Full stack trace of the exception:

Fatal Exception: ag.g
The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | DataStoreException{message=Failure performing sync query to AppSync., cause=ApiException{message=Could not retrieve the response body from the returned JSON, cause=mi.f0: stream was reset: CANCEL, recoverySuggestion=Sorry, we don’t have a recovery suggestion for this error.}, recoverySuggestion=Sorry, we don’t have a recovery suggestion for this error.}

Caused by com.amplifyframework.datastore.DataStoreException
Failure performing sync query to AppSync.

com.amplifyframework.datastore.appsync.AppSyncClient.lambda$sync$0 (AppSyncClient.java:115)
com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onResponse (AppSyncGraphQLOperation.java:138)
okhttp3.internal.connection.RealCall$AsyncCall.run (RealCall.kt:539)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:644)
java.lang.Thread.run (Thread.java:1012)

Caused by com.amplifyframework.api.ApiException
Could not retrieve the response body from the returned JSON

com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onResponse (AppSyncGraphQLOperation.java:138)
okhttp3.internal.connection.RealCall$AsyncCall.run (RealCall.kt:539)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:644)
java.lang.Thread.run (Thread.java:1012)

Caused by mi.f0
stream was reset: CANCEL

okhttp3.internal.http2.Http2Stream$FramingSource.read (Http2Stream.kt:381)
okhttp3.internal.connection.Exchange$ResponseBodySource.read (Exchange.kt:281)
okio.RealBufferedSource.read (RealBufferedSource.kt:192)
okio.RealBufferedSource.request (RealBufferedSource.kt:209)
okio.RealBufferedSource.require (RealBufferedSource.kt:202)
okio.GzipSource.consumeHeader (GzipSource.kt:104)
okio.GzipSource.read (GzipSource.kt:62)
okio.RealBufferedSource.select (RealBufferedSource.kt:232)
okhttp3.internal._UtilJvmKt.readBomAsCharset (-UtilJvm.kt:89)
okhttp3.ResponseBody.string (ResponseBody.kt:72)
com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onResponse (AppSyncGraphQLOperation.java:135)
okhttp3.internal.connection.RealCall$AsyncCall.run (RealCall.kt:539)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:644)
java.lang.Thread.run (Thread.java:1012)

It looks to me like there might be a try/catch block missing somewhere in the flow of this error (in the DataStore com.amplifyframework.datastore or the GraphQL API in com.amplifyframework.api).

This exception occurred for about 3% of users of our app, which is having a significant impact on the crash rate of our app. I would love your help -- please let me know if I can provide further details to help with solving this.

Not sure it's helpful but interestingly, 83% of the exceptions happen on Samsung phones, which is far from the distribution of device-type for our userbase. So there seems to be some relation between the crashes occurring more often on Samsung OS (although it does also happen on other not-customized OEMs like Google Pixels, but only about 1% of the crashes).

Reproduction steps (if applicable)

No response

Code Snippet

// I'm pretty sure it's happening in the AWS Amplify SDK 

Log output

// Put your logs below this line


amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@JornR94
Copy link
Author

JornR94 commented Jun 28, 2024

Update: similar to this issue and @mattcreaser proposed a solution to prevent this exception from happening, explanation here

@mattcreaser mattcreaser added bug Something isn't working datastore DataStore category/plugins labels Jun 28, 2024
@github-actions github-actions bot removed the pending-triage Issue is pending triage label Jun 28, 2024
@mattcreaser
Copy link
Member

We will look to see if this can be caught internally but the supplied workaround is also recommended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working datastore DataStore category/plugins
Projects
None yet
Development

No branches or pull requests

2 participants