apple / apple/sample-cloudkit-sync-engine
Implementation flaw
- Dominant language
- Swift
- Stars
- 270
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
I think there is an implementation error in the sample project - more specifically, a flaw in the design of CKSyncEngine.
In the SyncedDatabase file, line 350:
self.syncEngine.state.add(pendingRecordZoneChanges: pendingSaves)
This tells the syncEngine what to do when the time is right. Since this piece of information is *not* persisted in this call (I think its persisted in .stateUpdate(let event)), there is a chance that this information is lost if the app crashes between .add(pendingRecordZoneChanges: pendingSaves) and .stateUpdate(let event).
I know this is just a sample project, but I really think this is a flaw in the API design of CKSyncEngine since I do not see an easy way to guarantee correct behavior. A simple fix would be to make .add(pendingRecordZoneChanges: pendingSaves) (and similar methods) async and only complete after .stateUpdate(let event) was called.
What do you think?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in SyncedDatabase at line 350 and review how pendingRecordZoneChanges and the stateUpdate event are handled. Assess the crash window described in the issue and the proposed asynchronous API change; done requires a maintainer-confirmed resolution to the data-loss or API-design concern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- cloud, databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100