Ver código fonte

fix(JitsiParticipant): compare against specific error constant

dev1
paweldomas 5 anos atrás
pai
commit
6d1ccc5926
2 arquivos alterados com 6 adições e 6 exclusões
  1. 3
    5
      JitsiParticipant.js
  2. 3
    1
      modules/xmpp/Caps.js

+ 3
- 5
JitsiParticipant.js Ver arquivo

@@ -6,6 +6,7 @@ import { getLogger } from 'jitsi-meet-logger';
6 6
 import * as JitsiConferenceEvents from './JitsiConferenceEvents';
7 7
 import { ParticipantConnectionStatus }
8 8
     from './modules/connectivity/ParticipantConnectionStatus';
9
+import { ERROR_FEATURE_VERSION_MISMATCH } from './modules/xmpp/Caps';
9 10
 import * as MediaType from './service/RTC/MediaType';
10 11
 
11 12
 const logger = getLogger(__filename);
@@ -246,11 +247,8 @@ export default class JitsiParticipant {
246 247
 
247 248
         this._getFeaturesPromise = this._conference.xmpp.caps.getFeatures(this._jid, timeout)
248 249
             .catch(error => {
249
-                // FIXME there's a risk of getting into an endless loop should anything along the way decide to reject
250
-                //  with a string. Compare against a specific string instead.
251
-                // when we detect version mismatch we return a string as error
252
-                // we want to retry in such case
253
-                if (error && error.constructor === String) {
250
+                // Retry on feature version mismatch
251
+                if (error === ERROR_FEATURE_VERSION_MISMATCH) {
254 252
                     return this._conference.xmpp.caps.getFeatures(this._jid, timeout);
255 253
                 }
256 254
 

+ 3
- 1
modules/xmpp/Caps.js Ver arquivo

@@ -14,6 +14,8 @@ const IDENTITY_PROPERTIES = [ 'category', 'type', 'lang', 'name' ];
14 14
 const IDENTITY_PROPERTIES_FOR_COMPARE = [ 'category', 'type', 'lang' ];
15 15
 const HASH = 'sha-1';
16 16
 
17
+export const ERROR_FEATURE_VERSION_MISMATCH = 'Feature version mismatch';
18
+
17 19
 /**
18 20
  *
19 21
  * @param a
@@ -167,7 +169,7 @@ export default class Caps extends Listenable {
167 169
                         logger.error(`Expected node ${node} but received ${
168 170
                             receivedNode}`);
169 171
 
170
-                        return Promise.reject('Feature version mismatch');
172
+                        return Promise.reject(ERROR_FEATURE_VERSION_MISMATCH);
171 173
                     }
172 174
                 });
173 175
         }

Carregando…
Cancelar
Salvar