Skip to content

Commit 0a6dcd5

Browse files
authored
fix(DataStore): remove reconcile operations serially (#1137)
1 parent 3f9ece2 commit 0a6dcd5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Sync/SubscriptionSync/ReconcileAndLocalSave/ReconcileAndLocalSaveQueue.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ class ReconcileAndSaveQueue: ReconcileAndSaveOperationQueue {
7171
}
7272

7373
func addOperation(_ operation: ReconcileAndLocalSaveOperation, modelName: String) {
74+
7475
serialQueue.async {
7576
var reconcileAndLocalSaveOperationSink: AnyCancellable?
76-
7777
reconcileAndLocalSaveOperationSink = operation.publisher.sink { _ in
78-
self.reconcileAndLocalSaveOperationSinks.with { $0.remove(reconcileAndLocalSaveOperationSink) }
79-
self.modelReconcileAndSaveOperations[modelName]?[operation.id] = nil
80-
self.reconcileAndSaveQueueSubject.send(.operationRemoved(id: operation.id))
78+
self.serialQueue.async {
79+
self.reconcileAndLocalSaveOperationSinks.with { $0.remove(reconcileAndLocalSaveOperationSink) }
80+
self.modelReconcileAndSaveOperations[modelName]?[operation.id] = nil
81+
self.reconcileAndSaveQueueSubject.send(.operationRemoved(id: operation.id))
82+
}
8183
} receiveValue: { _ in }
8284

8385
self.reconcileAndLocalSaveOperationSinks.with { $0.insert(reconcileAndLocalSaveOperationSink) }

AmplifyPlugins/DataStore/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ SPEC CHECKSUMS:
118118

119119
PODFILE CHECKSUM: 04860e414d616b67d24ed3346a60700f427764b9
120120

121-
COCOAPODS: 1.9.3
121+
COCOAPODS: 1.10.1

0 commit comments

Comments
 (0)