amplify-android: Initial sync during DataStore initialization failed.
If a user runs the app first time before sign-in then next error has occurred:
09-04 20:31:33.707 9423-9479/com.sensodix E/amplify:aws-datastore: Error encountered in the DataStore.
AmplifyException {message=Initial cloud sync failed., cause=AmplifyException {message=Failure performing sync query to AppSync., cause=AmplifyException {message=Could not retrieve the response body from the returned JSON, cause=java.io.IOException: Failed to retrieve Cognito User Pools token., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Check your internet connection.}
at com.amplifyframework.datastore.syncengine.SyncProcessor.lambda$createHydrationTask$8$SyncProcessor(SyncProcessor.java:161)
at com.amplifyframework.datastore.syncengine.-$$Lambda$SyncProcessor$-2QSLtdRgTPoxsmAWkh9ybwd5JA.accept(lambda)
at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek$CompletableObserverImplementation.onError(CompletablePeek.java:88)
at io.reactivex.rxjava3.internal.operators.single.SingleFlatMapCompletable$FlatMapCompletableObserver.onError(SingleFlatMapCompletable.java:97)
at io.reactivex.rxjava3.internal.operators.single.SingleFlatMap$SingleFlatMapCallback$FlatMapSingleObserver.onError(SingleFlatMap.java:117)
at io.reactivex.rxjava3.internal.operators.completable.CompletableToSingle$ToSingle.onError(CompletableToSingle.java:73)
at io.reactivex.rxjava3.internal.util.AtomicThrowable.tryTerminateConsumer(AtomicThrowable.java:156)
at io.reactivex.rxjava3.internal.operators.flowable.FlowableFlatMapCompletableCompletable$FlatMapCompletableMainSubscriber.onError(FlowableFlatMapCompletableCompletable.java:149)
at io.reactivex.rxjava3.internal.operators.flowable.FlowableTake$TakeSubscriber.onError(FlowableTake.java:86)
at io.reactivex.rxjava3.internal.operators.flowable.FlowableFlattenIterable$FlattenIterableSubscriber.checkTerminated(FlowableFlattenIterable.java:406)
at io.reactivex.rxjava3.internal.operators.flowable.FlowableFlattenIterable$FlattenIterableSubscriber.drain(FlowableFlattenIterable.java:266)
at io.reactivex.rxjava3.internal.operators.flowable.FlowableFlattenIterable$FlattenIterableSubscriber.onError(FlowableFlattenIterable.java:192)
at io.reactivex.rxjava3.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onError(FlowableDoOnEach.java:111)
at io.reactivex.rxjava3.internal.util.AtomicThrowable.tryTerminateConsumer(AtomicThrowable.java:94)
at io.reactivex.rxjava3.internal.util.HalfSerializer.onError(HalfSerializer.java:67)
at io.reactivex.rxjava3.internal.operators.flowable.FlowableConcatMap$ConcatMapImmediate.innerError(FlowableConcatMap.java:210)
at io.reactivex.rxjava3.internal.operators.flowable.FlowableConcatMap$ConcatMapInner.onError(FlowableConcatMap.java:571)
at io.reactivex.rxjava3.internal.operators.single.SingleToFlowable$SingleToFlowableObserver.onError(SingleToFlowable.java:67)
at io.reactivex.rxjava3.internal.operators.single.SingleCreate$Emitter.tryOnError(SingleCreate.java:95)
at io.reactivex.rxjava3.internal.operators.single.SingleCreate$Emitter.onError(SingleCreate.java:81)
at com.amplifyframework.datastore.syncengine.-$$Lambda$PymunRoF4O3jbMDeD82w6kHUXIM.accept(lambda)
at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$sync$1(AppSyncClient.java:98)
at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$suvEma05s-p8v-66iE4cswLKYac.accept(lambda)
at com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onFailure(AppSyncGraphQLOperation.java:150)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:525)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: AmplifyException {message=Failure performing sync query to AppSync., cause=AmplifyException {message=Could not retrieve the response body from the returned JSON, cause=java.io.IOException: Failed to retrieve Cognito User Pools token., recoverySuggestion=Sorry, we don't have a suggest
09-04 20:31:33.708 9423-9467/com.sensodix E/amplify:aws-datastore: Failure encountered while attempting to start API sync.
AmplifyException {message=Initial sync during DataStore initialization failed., cause=java.lang.RuntimeException: AmplifyException {message=Failure performing sync query to AppSync., cause=AmplifyException {message=Could not retrieve the response body from the returned JSON, cause=java.io.IOException: Failed to retrieve Cognito User Pools token., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=There is a possibility that there is a bug if this error persists. Please take a look at
https://github.com/aws-amplify/amplify-android/issues to see if there are any existing issues that
match your scenario, and file an issue with the details of the bug if there isn't.}
at com.amplifyframework.datastore.syncengine.Orchestrator.lambda$startApiSync$4$Orchestrator(Orchestrator.java:279)
at com.amplifyframework.datastore.syncengine.-$$Lambda$Orchestrator$LZNjaZMRgCaJlw-lrjSVwfuZjK0.subscribe(lambda)
at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:40)
at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
at io.reactivex.rxjava3.internal.operators.completable.CompletableOnErrorComplete.subscribeActual(CompletableOnErrorComplete.java:35)
at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
at io.reactivex.rxjava3.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:64)
at io.reactivex.rxjava3.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:41)
at io.reactivex.rxjava3.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.RuntimeException: AmplifyException {message=Failure performing sync query to AppSync., cause=AmplifyException {message=Could not retrieve the response body from the returned JSON, cause=java.io.IOException: Failed to retrieve Cognito User Pools token., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
at io.reactivex.rxjava3.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46)
at io.reactivex.rxjava3.internal.observers.BlockingMultiObserver.blockingAwait(BlockingMultiObserver.java:145)
at io.reactivex.rxjava3.core.Completable.blockingAwait(Completable.java:1490)
at com.amplifyframework.datastore.syncengine.Orchestrator.lambda$startApiSync$4$Orchestrator(Orchestrator.java:276)
at com.amplifyframework.datastore.syncengine.-$$Lambda$Orchestrator$LZNjaZMRgCaJlw-lrjSVwfuZjK0.subscribe(lambda)
at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:40)
at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
at io.reactivex.rxjava3.internal.operators.completable.CompletableOnErrorComplete.subscribeActual(CompletableOnErrorComplete.java:35)
at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
at io.reactivex.rxjava3.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:64)
at io.reactivex.rxjava3.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:41)
at io.reactivex.rxjava3.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: AmplifyException {message=Failure performing sync query to AppSync., cause=AmplifyException {message=Could not retrieve the response body from the returned JSON, cause=java.io.IOException: Failed to retrieve Cognito User Pools token., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$sync$1(AppSyncClient.java:98)
at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$suvEma05s-p8v-66iE4cswLKYac.accept(lambda)
at com.amplifyframework.api.aws.AppSyncGraphQLOperation$OkHttpCallback.onFailure(AppSyn
My environment: Amplify Framework 1.3.1 Addroid API 22, 29
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (6 by maintainers)
hi @richardmcclellan, thank you for your support. I’ll try this approach.
You shouldn’t need to. It should only be called once.
This is a bug 😃. I fixed it yesterday (https://github.com/aws-amplify/amplify-android/pull/952), and it will go out in our next release.