caiyue1993/IceCream

Chunking the syncing process to less than 400 ops/request still leads to error: ErrorHandler.Chunk: Limit Exceeded: the request to the server is too large.CKError.Code: 27

Opened this issue · 2 comments

Expected behavior

I am inside of syncRecordsToCloudKit function of SyncEngine class. Inside the completion block called modifyRecordsCompletionBlock of modifyOpe, chunkItUp function is used to request less than 400 operations on a single request:

            let chunkedRecords = recordsToStore.chunkItUp(by: 300)
            print("CHUNKING BY: \(chunkNumber)")

            for chunk in chunkedRecords {
            print("chunk: \(chunk.count)")
                self.syncRecordsToCloudKit(recordsToStore: chunk, recordIDsToDelete: recordIDsToDelete, completion: completion)
            }

This should sync data 300 ops at a time without a problem.

Actual behavior(optional)

However, I get an error message as if I went over 400 operations per request:

ErrorHandler.Chunk: Limit Exceeded: the request to the server is too large.CKError.Code: 27

output:
CHUNKING BY: 300
chunk: 300
chunk: 300
chunk: 157

This problem results in not even single data being synced to the iCloud. How do we bypass this problem?

Seems like the missing piece of the puzzle is chunking the recordIDsToDelete as well ...

Hi @jamesryu108 and thanks to @gghanak, I've proposed #175 to fix this :)