From 95343967c8eb042b42e908e01d969a0b428647f2 Mon Sep 17 00:00:00 2001 From: Michael Law <1365977+lawmicha@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:13:28 -0400 Subject: [PATCH] fix(datastore): call errorHandler in Sync operation when failure --- .../Sync/InitialSync/InitialSyncOperation.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOperation.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOperation.swift index 8ba67f6295..d90392260a 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOperation.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOperation.swift @@ -130,10 +130,13 @@ final class InitialSyncOperation: AsynchronousOperation { switch result { case .failure(let apiError): if self.isAuthSignedOutError(apiError: apiError) { - self.dataStoreConfiguration.errorHandler(DataStoreError.api(apiError)) + self.log.error("Sync for \(self.modelSchema.name) failed due to signed out error \(apiError.errorDescription)") } + // TODO: Retry query on error - self.finish(result: .failure(DataStoreError.api(apiError))) + let error = DataStoreError.api(apiError) + self.dataStoreConfiguration.errorHandler(error) + self.finish(result: .failure(error)) case .success(let graphQLResult): self.handleQueryResults(lastSyncTime: lastSyncTime, graphQLResult: graphQLResult) }