From 42d570e6231eaff586a09a70d25f2223024d97b6 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 14 Oct 2019 00:50:40 -0400 Subject: [PATCH] Remove timeout for file sync uploads Regression from 50b65b3010, and a proper fix a9c10309f7 --- chrome/content/zotero/xpcom/http.js | 7 +++-- chrome/content/zotero/xpcom/storage/webdav.js | 1 + chrome/content/zotero/xpcom/storage/zfs.js | 27 ++----------------- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index 856a173f95..d92b6b1d84 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -138,7 +138,8 @@ Zotero.HTTP = new function() { * @param {Number[]|false} [options.successCodes] - HTTP status codes that are considered * successful, or FALSE to allow all * @param {Zotero.CookieSandbox} [options.cookieSandbox] - Cookie sandbox object - * @param {Number} [options.timeout = 30000] - Request timeout specified in milliseconds + * @param {Number} [options.timeout = 30000] - Request timeout specified in milliseconds, or 0 + * for no timeout * @param {Number[]} [options.errorDelayIntervals] - Array of milliseconds to wait before * retrying after 5xx error; if unspecified, a default set is used * @param {Number} [options.errorDelayMax = 3600000] - Milliseconds to wait before stopping @@ -387,7 +388,9 @@ Zotero.HTTP = new function() { } // Set timeout - xmlhttp.timeout = options.timeout || 30000; + if (options.timeout !== 0) { + xmlhttp.timeout = options.timeout || 30000; + } xmlhttp.ontimeout = function() { deferred.reject(new Zotero.HTTP.TimeoutException(options.timeout)); diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js index 22576ef041..d9b7e9b0a1 100644 --- a/chrome/content/zotero/xpcom/storage/webdav.js +++ b/chrome/content/zotero/xpcom/storage/webdav.js @@ -558,6 +558,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { }, errorDelayIntervals: this.ERROR_DELAY_INTERVALS, errorDelayMax: this.ERROR_DELAY_MAX, + timeout: 0, debug: true } ); diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 6c11960535..37d3720ec4 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -645,7 +645,8 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = { }); }, debug: true, - successCodes: [201] + successCodes: [201], + timeout: 0 } ); } @@ -683,30 +684,6 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = { return this._uploadFile(request, item, params); } } - // Alternative to the above. There was at least one report of this happening even though - // a timeout isn't being set, with 2152398850 (NS_BINDING_ABORTED) from the channel: - // https://forums.zotero.org/discussion/79286/ - else if (e instanceof Zotero.HTTP.TimeoutException) { - Zotero.logError(e); - if (this._s3ConsecutiveFailures >= this._maxS3ConsecutiveFailures) { - Zotero.debug(this._s3ConsecutiveFailures - + " consecutive S3 failures -- aborting", 1); - this._s3ConsecutiveFailures = 0; - let e = Zotero.getString('sync.storage.error.zfs.restart', Zotero.appName); - throw new Error(e); - } - else { - Zotero.logError("S3 timed out (" + item.libraryKey + ") -- retrying upload"); - if (this._s3Backoff < this._maxS3Backoff) { - this._s3Backoff *= 2; - } - this._s3ConsecutiveFailures++; - Zotero.debug("Delaying " + item.libraryKey + " upload for " - + this._s3Backoff + " seconds", 2); - yield Zotero.Promise.delay(this._s3Backoff * 1000); - return this._uploadFile(request, item, params); - } - } else if (e.status == 500) { // TODO: localize throw new Error("File upload failed. Please try again.");