You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
All: Display last sync error unless it's a timeout or network error
This commit is contained in:
@@ -53,7 +53,7 @@ shim.isElectron = () => {
|
||||
// Node requests can go wrong is so many different ways and with so
|
||||
// many different error messages... This handler inspects the error
|
||||
// and decides whether the request can safely be repeated or not.
|
||||
function fetchRequestCanBeRetried(error) {
|
||||
shim.fetchRequestCanBeRetried = function(error) {
|
||||
if (!error) return false;
|
||||
|
||||
// Unfortunately the error 'Network request failed' doesn't have a type
|
||||
@@ -86,7 +86,7 @@ function fetchRequestCanBeRetried(error) {
|
||||
if (error.code === "ETIMEDOUT") return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
shim.fetchWithRetry = async function(fetchFn, options = null) {
|
||||
const { time } = require("lib/time-utils.js");
|
||||
@@ -101,7 +101,7 @@ shim.fetchWithRetry = async function(fetchFn, options = null) {
|
||||
const response = await fetchFn();
|
||||
return response;
|
||||
} catch (error) {
|
||||
if (fetchRequestCanBeRetried(error)) {
|
||||
if (shim.fetchRequestCanBeRetried(error)) {
|
||||
retryCount++;
|
||||
if (retryCount > options.maxRetry) throw error;
|
||||
await time.sleep(retryCount * 3);
|
||||
|
||||
@@ -71,9 +71,10 @@ class Synchronizer {
|
||||
if (report.deleteLocal) lines.push(_("Deleted local items: %d.", report.deleteLocal));
|
||||
if (report.deleteRemote) lines.push(_("Deleted remote items: %d.", report.deleteRemote));
|
||||
if (report.fetchingTotal && report.fetchingProcessed) lines.push(_("Fetched items: %d/%d.", report.fetchingProcessed, report.fetchingTotal));
|
||||
if (!report.completedTime && report.state) lines.push(_('State: "%s".', report.state));
|
||||
if (!report.completedTime && report.state) lines.push(_('State: "%s".', Synchronizer.stateToLabel(report.state)));
|
||||
if (report.cancelling && !report.completedTime) lines.push(_("Cancelling..."));
|
||||
if (report.completedTime) lines.push(_("Completed: %s", time.unixMsToLocalDateTime(report.completedTime)));
|
||||
if (report.errors && report.errors.length) lines.push(_("Last error: %s", report.errors[report.errors.length - 1].toString().substr(0, 500)));
|
||||
|
||||
return lines;
|
||||
}
|
||||
@@ -157,6 +158,12 @@ class Synchronizer {
|
||||
return this.cancelling_;
|
||||
}
|
||||
|
||||
static stateToLabel(state) {
|
||||
if (state === "idle") return _("Idle");
|
||||
if (state === "in_progress") return _("In progress");
|
||||
return state;
|
||||
}
|
||||
|
||||
// Synchronisation is done in three major steps:
|
||||
//
|
||||
// 1. UPLOAD: Send to the sync target the items that have changed since the last sync.
|
||||
@@ -603,7 +610,9 @@ class Synchronizer {
|
||||
this.logger().info(error.message);
|
||||
} else {
|
||||
this.logger().error(error);
|
||||
this.progressReport_.errors.push(error);
|
||||
|
||||
// Don't save to the report errors that are due to things like temporary network errors or timeout.
|
||||
if (!shim.fetchRequestCanBeRetried(error)) this.progressReport_.errors.push(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user