From ede600458af6e7d66e58e9fb2960bb605859dd44 Mon Sep 17 00:00:00 2001
From: Laurent Cozic <laurent@cozic.net>
Date: Wed, 3 Feb 2021 11:58:18 +0000
Subject: [PATCH] All: Regression: Fixed network request repeat mechanism

---
 packages/lib/shim.ts | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/packages/lib/shim.ts b/packages/lib/shim.ts
index b5ae64793d..80301ee4d1 100644
--- a/packages/lib/shim.ts
+++ b/packages/lib/shim.ts
@@ -21,6 +21,14 @@ let react_: any = null;
 const shim = {
 	Geolocation: null as any,
 
+	msleep_: (ms: number) => {
+		return new Promise((resolve: Function) => {
+			shim.setTimeout(() => {
+				resolve(null);
+			}, ms);
+		});
+	},
+
 	isNode: () => {
 		if (typeof process === 'undefined') return false;
 		if (shim.isElectron()) return true;
@@ -140,8 +148,6 @@ const shim = {
 	},
 
 	fetchWithRetry: async function(fetchFn: Function, options: any = null) {
-		const time = require('./time');
-
 		if (!options) options = {};
 		if (!options.timeout) options.timeout = 1000 * 120; // ms
 		if (!('maxRetry' in options)) options.maxRetry = shim.fetchMaxRetry_;
@@ -155,7 +161,7 @@ const shim = {
 				if (shim.fetchRequestCanBeRetried(error)) {
 					retryCount++;
 					if (retryCount > options.maxRetry) throw error;
-					await time.sleep(retryCount * 3);
+					await shim.msleep_(retryCount * 3000);
 				} else {
 					throw error;
 				}