1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

Desktop: Only repeat failed requests up to 3 times during sync

This commit is contained in:
Laurent Cozic
2019-07-29 10:12:23 +02:00
parent af4aa01b75
commit 2c6b291b9b
2 changed files with 22 additions and 4 deletions

View File

@@ -104,12 +104,20 @@ shim.fetchRequestCanBeRetried = function(error) {
return false;
};
shim.fetchMaxRetry_ = 5;
shim.fetchMaxRetrySet = v => {
const previous = shim.fetchMaxRetry_;
shim.fetchMaxRetry_ = v;
return previous;
}
shim.fetchWithRetry = async function(fetchFn, options = null) {
const { time } = require('lib/time-utils.js');
if (!options) options = {};
if (!options.timeout) options.timeout = 1000 * 120; // ms
if (!('maxRetry' in options)) options.maxRetry = 5;
if (!('maxRetry' in options)) options.maxRetry = shim.fetchMaxRetry_;
let retryCount = 0;
while (true) {