Przeglądaj źródła

Adds a retry logic when fetching conference numbers and pin.

master
damencho 6 lat temu
rodzic
commit
21fb225726

+ 25
- 2
react/features/base/util/httpUtils.js Wyświetl plik

@@ -1,15 +1,25 @@
1
+import { timeoutPromise } from './timeoutPromise';
2
+
1 3
 const logger = require('jitsi-meet-logger').getLogger(__filename);
2 4
 
5
+/**
6
+ * The number of milliseconds before deciding that we need retry a fetch request.
7
+ *
8
+ * @type {number}
9
+ */
10
+const RETRY_TIMEOUT = 3000;
11
+
3 12
 /**
4 13
  * Wrapper around fetch GET requests to handle json-ifying the response
5 14
  * and logging errors.
6 15
  *
7 16
  * @param {string} url - The URL to perform a GET against.
17
+ * @param {?boolean} retry - Whether the request will be retried after short timeout.
8 18
  * @returns {Promise<Object>} The response body, in JSON format, will be
9 19
  * through the Promise.
10 20
  */
11
-export function doGetJSON(url) {
12
-    return fetch(url)
21
+export function doGetJSON(url, retry) {
22
+    const fetchPromise = fetch(url)
13 23
         .then(response => {
14 24
             const jsonify = response.json();
15 25
 
@@ -25,4 +35,17 @@ export function doGetJSON(url) {
25 35
 
26 36
             return Promise.reject(error);
27 37
         });
38
+
39
+    if (retry) {
40
+        return timeoutPromise(fetchPromise, RETRY_TIMEOUT)
41
+            .catch(response => {
42
+                if (response.status >= 400 && response.status < 500) {
43
+                    return Promise.reject(response);
44
+                }
45
+
46
+                return timeoutPromise(fetchPromise, RETRY_TIMEOUT);
47
+            });
48
+    }
49
+
50
+    return fetchPromise;
28 51
 }

+ 2
- 2
react/features/invite/components/dial-in-summary/web/DialInSummary.js Wyświetl plik

@@ -177,7 +177,7 @@ class DialInSummary extends Component<Props, State> {
177 177
             return Promise.resolve();
178 178
         }
179 179
 
180
-        return doGetJSON(`${dialInConfCodeUrl}?conference=${room}@${mucURL}`)
180
+        return doGetJSON(`${dialInConfCodeUrl}?conference=${room}@${mucURL}`, true)
181 181
             .catch(() => Promise.reject(this.props.t('info.genericError')));
182 182
     }
183 183
 
@@ -204,7 +204,7 @@ class DialInSummary extends Component<Props, State> {
204 204
             URLSuffix = `?conference=${room}@${mucURL}`;
205 205
         }
206 206
 
207
-        return doGetJSON(`${dialInNumbersUrl}${URLSuffix}`)
207
+        return doGetJSON(`${dialInNumbersUrl}${URLSuffix}`, true)
208 208
             .catch(() => Promise.reject(this.props.t('info.genericError')));
209 209
     }
210 210
 

+ 2
- 2
react/features/invite/functions.js Wyświetl plik

@@ -48,7 +48,7 @@ export function getDialInConferenceID(
48 48
 
49 49
     const conferenceIDURL = `${baseUrl}?conference=${roomName}@${mucURL}`;
50 50
 
51
-    return doGetJSON(conferenceIDURL);
51
+    return doGetJSON(conferenceIDURL, true);
52 52
 }
53 53
 
54 54
 /**
@@ -71,7 +71,7 @@ export function getDialInNumbers(
71 71
 
72 72
     const fullUrl = `${url}?conference=${roomName}@${mucURL}`;
73 73
 
74
-    return doGetJSON(fullUrl);
74
+    return doGetJSON(fullUrl, true);
75 75
 }
76 76
 
77 77
 /**

Ładowanie…
Anuluj
Zapisz