From af2b6207b2cb1637bc1e06b97873ff628eb32e80 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 10 Oct 2019 19:13:47 -0400 Subject: [PATCH] Decrease batch size and increase HTTP timeout for sync uploads Some write requests are taking > 30 seconds --- chrome/content/zotero/xpcom/sync/syncAPIClient.js | 8 ++++++-- chrome/content/zotero/xpcom/sync/syncEngine.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync/syncAPIClient.js b/chrome/content/zotero/xpcom/sync/syncAPIClient.js index 8515ccf007..38aefc0769 100644 --- a/chrome/content/zotero/xpcom/sync/syncAPIClient.js +++ b/chrome/content/zotero/xpcom/sync/syncAPIClient.js @@ -46,6 +46,7 @@ Zotero.Sync.APIClient = function (options) { Zotero.Sync.APIClient.prototype = { MAX_OBJECTS_PER_REQUEST: 100, MIN_GZIP_SIZE: 1000, + UPLOAD_TIMEOUT: 60, getKeyInfo: Zotero.Promise.coroutine(function* (options={}) { @@ -379,7 +380,8 @@ Zotero.Sync.APIClient.prototype = { "If-Unmodified-Since-Version": libraryVersion }, body: json, - successCodes: [200, 412] + successCodes: [200, 412], + timeout: this.UPLOAD_TIMEOUT, }); this._check412(xmlhttp); return { @@ -413,7 +415,8 @@ Zotero.Sync.APIClient.prototype = { headers: { "If-Unmodified-Since-Version": libraryVersion }, - successCodes: [204, 412] + successCodes: [204, 412], + timeout: this.UPLOAD_TIMEOUT, }); this._check412(xmlhttp); return this._getLastModifiedVersion(xmlhttp); @@ -481,6 +484,7 @@ Zotero.Sync.APIClient.prototype = { }, body: JSON.stringify(data), successCodes: [200, 412], + timeout: this.UPLOAD_TIMEOUT, debug: true } ); diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index eb4f530c70..5d746d8d44 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -50,8 +50,8 @@ Zotero.Sync.Data.Engine = function (options) { this.libraryID = options.libraryID; this.library = Zotero.Libraries.get(options.libraryID); this.libraryTypeID = this.library.libraryTypeID; - this.uploadBatchSize = 25; - this.uploadDeletionBatchSize = 50; + this.uploadBatchSize = 10; + this.uploadDeletionBatchSize = 25; this.maxUploadTries = 5; this.failed = false;