Skip to content

Commit 9f77181

Browse files
authored
fix(DataStore): Various mutation sync fixes (#1355)
- Correctly subclass SyncMutationToCloudOperation as an AsynchronousOperation instead of an Operation - Dispatch start events when sync includes dropped mutations Additional work: - chore(DataStore): Removed redundant error & finish calls in isCancelled guards - chore(DataStore): Improve OperationCancelledError handling - test(Core): Added nullability test for AtomicValue.with - test(DataStore): Stabilize subscription end-to-end integ test - test(DataStore): Enable ThreadSanitizer for integ tests - test(DataStore): Disabled unimplemented OIDC tests in test scheme - test(DataStore): Disable OIDC tests
1 parent 23eb7bc commit 9f77181

File tree

22 files changed

+249
-88
lines changed

22 files changed

+249
-88
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ credentials-mc.json
5252
fastlane/report.xml
5353

5454
# Amplify artifacts, such as used for integ tests
55-
amplify
55+
#amplify/
56+
AmplifyPlugins/**/amplify
5657
amplify/\#current-cloud-backend
5758
amplify/.config/local-*
5859
amplify/logs

Amplify.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@
609609
FA9D6C1B238DEEEB00C7DD9F /* ConcurrentDispatcherPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAF1B8872339633C007F1435 /* ConcurrentDispatcherPerformanceTests.swift */; };
610610
FA9D6C1E238DEF0E00C7DD9F /* DefaultHubPluginPerformanceTestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAF1B88A23397791007F1435 /* DefaultHubPluginPerformanceTestHelpers.swift */; };
611611
FA9D6C1F238DEF1100C7DD9F /* SerialDispatcherPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA317107232AE8DF009BC140 /* SerialDispatcherPerformanceTests.swift */; };
612+
FA9F939626BAF73F00805607 /* OperationCancelledError.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA9F939526BAF73F00805607 /* OperationCancelledError.swift */; };
612613
FA9FB7792329D4D400C04D32 /* HubFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA9FB7782329D4D400C04D32 /* HubFilter.swift */; };
613614
FA9FB77B2329D4FB00C04D32 /* UnsubscribeToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA9FB77A2329D4FB00C04D32 /* UnsubscribeToken.swift */; };
614615
FA9FB77D232AA0D800C04D32 /* FilteredListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA9FB77C232AA0D800C04D32 /* FilteredListener.swift */; };
@@ -1591,6 +1592,7 @@
15911592
FA8EE780238628490097E4F1 /* Persistable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Persistable.swift; sourceTree = "<group>"; };
15921593
FA8EE78223862DDB0097E4F1 /* AnyModel+Schema.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AnyModel+Schema.swift"; sourceTree = "<group>"; };
15931594
FA8F4D232395B1B600861D91 /* MutationEvent+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MutationEvent+Model.swift"; sourceTree = "<group>"; };
1595+
FA9F939526BAF73F00805607 /* OperationCancelledError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationCancelledError.swift; sourceTree = "<group>"; };
15941596
FA9FB7782329D4D400C04D32 /* HubFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HubFilter.swift; sourceTree = "<group>"; };
15951597
FA9FB77A2329D4FB00C04D32 /* UnsubscribeToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsubscribeToken.swift; sourceTree = "<group>"; };
15961598
FA9FB77C232AA0D800C04D32 /* FilteredListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilteredListener.swift; sourceTree = "<group>"; };
@@ -3303,6 +3305,7 @@
33033305
FA5704C8245F3C6900392C19 /* AmplifyInProcessReportingOperation.swift */,
33043306
FA249EE624C5FA49009B3CE8 /* AmplifyInProcessReportingOperation+Combine.swift */,
33053307
FA56F72622B14BF70039754A /* AmplifyOperation.swift */,
3308+
FA9F939526BAF73F00805607 /* OperationCancelledError.swift */,
33063309
FAA7A5A524C0CC8F00CA863F /* AmplifyOperation+Combine.swift */,
33073310
FA5704CA245F58C600392C19 /* AmplifyOperation+Hub.swift */,
33083311
FAB9D810233BF5F600928AA9 /* AmplifyOperationContext.swift */,
@@ -5050,6 +5053,7 @@
50505053
B4B5CC812457B0690019C783 /* AuthFetchUserAttributesRequest.swift in Sources */,
50515054
B493E69324524E8C00D9E521 /* AuthUserAttribute.swift in Sources */,
50525055
B450741524115C340098F02D /* AuthSignInResult.swift in Sources */,
5056+
FA9F939626BAF73F00805607 /* OperationCancelledError.swift in Sources */,
50535057
B468841A2460A98E00221268 /* AuthForgetDeviceRequest.swift in Sources */,
50545058
217855C3237F84D700A30D19 /* RESTRequest.swift in Sources */,
50555059
975751AD24CA35F000FA0A6E /* IssueInfoHelper.swift in Sources */,

Amplify/Categories/API/Error/APIError.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ extension APIError: AmplifyError {
4747
) {
4848
if let error = error as? Self {
4949
self = error
50+
} else if error.isOperationCancelledError {
51+
self = .unknown("Operation cancelled", "", error)
5052
} else {
5153
self = .unknown(errorDescription, recoverySuggestion, error)
5254
}

Amplify/Categories/Analytics/Error/AnalyticsError.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ extension AnalyticsError: AmplifyError {
5858
) {
5959
if let error = error as? Self {
6060
self = error
61+
} else if error.isOperationCancelledError {
62+
self = .unknown("Operation cancelled", error)
6163
} else {
6264
self = .unknown(errorDescription, error)
6365
}

Amplify/Categories/Auth/Error/AuthError.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ extension AuthError: AmplifyError {
8888
) {
8989
if let error = error as? Self {
9090
self = error
91+
} else if error.isOperationCancelledError {
92+
self = .unknown("Operation cancelled", error)
9193
} else {
9294
self = .unknown(errorDescription, error)
9395
}

Amplify/Categories/DataStore/DataStoreError.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ extension DataStoreError: AmplifyError {
108108
self = error
109109
} else if let amplifyError = error as? AmplifyError {
110110
self = .api(amplifyError)
111+
} else if error.isOperationCancelledError {
112+
self = .unknown("Operation cancelled", "", error)
111113
} else {
112114
self = .unknown(errorDescription, recoverySuggestion, error)
113115
}

Amplify/Categories/Predictions/Error/PredictionsError.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ extension PredictionsError: AmplifyError {
8080
) {
8181
if let error = error as? Self {
8282
self = error
83+
} else if error.isOperationCancelledError {
84+
self = .unknown("Operation cancelled", "", error)
8385
} else {
8486
self = .unknown(errorDescription, recoverySuggestion, error)
8587
}

Amplify/Categories/Storage/Error/StorageError.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ extension StorageError: AmplifyError {
8686
) {
8787
if let error = error as? Self {
8888
self = error
89+
} else if error.isOperationCancelledError {
90+
self = .unknown("Operation cancelled", error)
8991
} else {
9092
self = .unknown(errorDescription, error)
9193
}

Amplify/Core/Support/AmplifyOperation+Combine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extension AmplifyOperation {
6060
/// - Returns: A publisher that either completes successfully (if the underlying
6161
/// error of `error` is a cancellation) or re-emits the existing error
6262
private func interceptCancellation(error: Failure) -> AnyPublisher<Success, Failure> {
63-
if error.underlyingError is OperationCancelledError {
63+
if error.isOperationCancelledError {
6464
return Empty<Success, Failure>(completeImmediately: true).eraseToAnyPublisher()
6565
} else {
6666
return Fail<Success, Failure>(error: error).eraseToAnyPublisher()

Amplify/Core/Support/AmplifyOperation.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import Foundation
1818
/// Pausable/resumable tasks that do not require Hub dispatching should use AsynchronousOperation instead.
1919
open class AmplifyOperation<Request: AmplifyOperationRequest, Success, Failure: AmplifyError>: AsynchronousOperation {
2020

21-
struct OperationCancelledError: Error { }
22-
2321
/// The concrete Request associated with this operation
2422
public typealias Request = Request
2523

0 commit comments

Comments
 (0)