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.
This commit is contained in:
parent
f008843fc5
commit
1f60df0044
|
@ -64,16 +64,40 @@ Zotero.Sync.Storage.StreamListener.prototype = {
|
||||||
onStopRequest: function (request, context, status) {
|
onStopRequest: function (request, context, status) {
|
||||||
Zotero.debug('onStopRequest with ' + status);
|
Zotero.debug('onStopRequest with ' + status);
|
||||||
|
|
||||||
|
// Some errors from https://developer.mozilla.org/en-US/docs/Table_Of_Errors
|
||||||
|
var msg = "";
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0:
|
// Normal
|
||||||
case 0x804b0002: // NS_BINDING_ABORTED
|
case 0:
|
||||||
this._onStop(request, status);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
// NS_BINDING_ABORTED
|
||||||
throw ("Unexpected request status " + status
|
case 0x804b0002:
|
||||||
+ " in Zotero.Sync.Storage.StreamListener.onStopRequest()");
|
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
|
// nsIWebProgressListener
|
||||||
|
@ -170,7 +194,13 @@ Zotero.Sync.Storage.StreamListener.prototype = {
|
||||||
|
|
||||||
if (!cancelled && request instanceof Components.interfaces.nsIHttpChannel) {
|
if (!cancelled && request instanceof Components.interfaces.nsIHttpChannel) {
|
||||||
request.QueryInterface(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);
|
request.QueryInterface(Components.interfaces.nsIRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user