Bug 1414438 - Use `getBatched` instead of `get` to backfill records r?kitcambridge
MozReview-Commit-ID: LLTg0ae5BbW
***
Bug 1414438 - Use `getBatched` instead of `get` in sync
--- a/services/sync/modules/engines.js
+++ b/services/sync/modules/engines.js
@@ -1194,35 +1194,33 @@ SyncEngine.prototype = {
// every subsequent sync just adds noise.
this.previousFailed = failedInCurrentSync;
let backfilledItems = this.itemSource();
backfilledItems.sort = "newest";
backfilledItems.full = true;
- // `get` includes the list of IDs as a query parameter, so we need to fetch
+ // `getBatched` includes the list of IDs as a query parameter, so we need to fetch
// records in chunks to avoid exceeding URI length limits.
for (let ids of PlacesSyncUtils.chunkArray(idsToBackfill, this.guidFetchBatchSize)) {
backfilledItems.ids = ids;
- let resp = await backfilledItems.get();
- if (!resp.success) {
- resp.failureCode = ENGINE_DOWNLOAD_FAIL;
- throw resp;
+ let {response, records} = await backfilledItems.getBatched(this.downloadBatchSize);
+ if (!response.success) {
+ response.failureCode = ENGINE_DOWNLOAD_FAIL;
+ throw response;
}
let maybeYield = Async.jankYielder();
let backfilledRecordsToApply = [];
let failedInBackfill = [];
- for (let json of resp.obj) {
+ for (let record of records) {
await maybeYield();
- let record = new this._recordObj();
- record.deserialize(json);
let { shouldApply, error } = await this._maybeReconcile(record);
if (error) {
failedInBackfill.push(record.id);
count.failed++;
continue;
}
if (!shouldApply) {