You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-30 23:44:55 +02:00
All: Regression: Fixed network request repeat mechanism
This commit is contained in:
@ -21,6 +21,14 @@ let react_: any = null;
|
|||||||
const shim = {
|
const shim = {
|
||||||
Geolocation: null as any,
|
Geolocation: null as any,
|
||||||
|
|
||||||
|
msleep_: (ms: number) => {
|
||||||
|
return new Promise((resolve: Function) => {
|
||||||
|
shim.setTimeout(() => {
|
||||||
|
resolve(null);
|
||||||
|
}, ms);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
isNode: () => {
|
isNode: () => {
|
||||||
if (typeof process === 'undefined') return false;
|
if (typeof process === 'undefined') return false;
|
||||||
if (shim.isElectron()) return true;
|
if (shim.isElectron()) return true;
|
||||||
@ -140,8 +148,6 @@ const shim = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
fetchWithRetry: async function(fetchFn: Function, options: any = null) {
|
fetchWithRetry: async function(fetchFn: Function, options: any = null) {
|
||||||
const time = require('./time');
|
|
||||||
|
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
if (!options.timeout) options.timeout = 1000 * 120; // ms
|
if (!options.timeout) options.timeout = 1000 * 120; // ms
|
||||||
if (!('maxRetry' in options)) options.maxRetry = shim.fetchMaxRetry_;
|
if (!('maxRetry' in options)) options.maxRetry = shim.fetchMaxRetry_;
|
||||||
@ -155,7 +161,7 @@ const shim = {
|
|||||||
if (shim.fetchRequestCanBeRetried(error)) {
|
if (shim.fetchRequestCanBeRetried(error)) {
|
||||||
retryCount++;
|
retryCount++;
|
||||||
if (retryCount > options.maxRetry) throw error;
|
if (retryCount > options.maxRetry) throw error;
|
||||||
await time.sleep(retryCount * 3);
|
await shim.msleep_(retryCount * 3000);
|
||||||
} else {
|
} else {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user