www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 1f60df0044ed01c40a0886ce8ff6f6acb4b5006c
parent f008843fc5b15a0a21fcdadcf573de8699a3436c
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 24 Apr 2014 18:01:55 -0400

Don't hang file sync on network errors

Network errors (where the connection itself failed, rather than failed
HTTP requests) were being thrown directly in the stream listener, which
prevented the Zotero.Sync.Storage.Request -- and therefore the file sync
-- from ever completing.

Diffstat:
Mchrome/content/zotero/xpcom/storage/streamListener.js | 48+++++++++++++++++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/chrome/content/zotero/xpcom/storage/streamListener.js b/chrome/content/zotero/xpcom/storage/streamListener.js @@ -64,16 +64,40 @@ Zotero.Sync.Storage.StreamListener.prototype = { onStopRequest: function (request, context, status) { Zotero.debug('onStopRequest with ' + status); + // Some errors from https://developer.mozilla.org/en-US/docs/Table_Of_Errors + var msg = ""; switch (status) { - case 0: - case 0x804b0002: // NS_BINDING_ABORTED - this._onStop(request, status); - break; - - default: - throw ("Unexpected request status " + status - + " in Zotero.Sync.Storage.StreamListener.onStopRequest()"); + // Normal + case 0: + break; + + // NS_BINDING_ABORTED + case 0x804b0002: + msg = "Request cancelled"; + break; + + // NS_ERROR_NET_INTERRUPT + case 0x804B0047: + msg = "Request interrupted"; + break; + + // NS_ERROR_NET_TIMEOUT + case 0x804B000E: + msg = "Request timed out"; + break; + + default: + msg = "Request failed"; + break; } + + if (msg) { + msg += " in Zotero.Sync.Storage.StreamListener.onStopRequest() (" + status + ")"; + Components.utils.reportError(msg); + Zotero.debug(msg, 1); + } + + this._onStop(request, status); }, // nsIWebProgressListener @@ -170,7 +194,13 @@ Zotero.Sync.Storage.StreamListener.prototype = { if (!cancelled && request instanceof Components.interfaces.nsIHttpChannel) { request.QueryInterface(Components.interfaces.nsIHttpChannel); - status = request.responseStatus; + try { + status = request.responseStatus; + } + catch (e) { + Zotero.debug("Request responseStatus not available", 1); + status = 0; + } request.QueryInterface(Components.interfaces.nsIRequest); }