Skip to content

Commit

Permalink
fix(XmppConnection) limit retries to 3, bail afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Sep 24, 2024
1 parent 5671c5d commit 4be1919
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion modules/xmpp/ResumeTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export default class ResumeTask {
this._retryDelay = undefined;
}

/**
* @returns {number} - The amount of retries.
*/
get retryCount() {
return this._resumeRetryN;
}

/**
* @returns {number|undefined} - How much the app will wait before trying to resume the XMPP connection. When
* 'undefined' it means that no resume task was not scheduled.
Expand Down Expand Up @@ -81,7 +88,6 @@ export default class ResumeTask {
// 1st retry: 1.5s - 3s
// 2nd retry: 3s - 9s
// 3rd and next retry: 4.5s - 27s
this._resumeRetryN = Math.min(3, this._resumeRetryN);
this._retryDelay = getJitterDelay(
/* retry */ this._resumeRetryN,
/* minDelay */ this._resumeRetryN * 1500,
Expand Down
13 changes: 12 additions & 1 deletion modules/xmpp/XmppConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import PingConnectionPlugin from './strophe.ping';

const logger = getLogger(__filename);

/**
* Maximum number of tries to resume.
*/
const MAX_RESUME_TRIES = 3;

/**
* The lib-jitsi-meet layer for {@link Strophe.Connection}.
*/
Expand Down Expand Up @@ -644,7 +649,13 @@ export default class XmppConnection extends Listenable {
if (resumeToken) {
this._resumeTask.schedule();

return true;
const r = this._resumeTask.retryCount <= MAX_RESUME_TRIES;

if (!r) {
logger.warn(`Maximum resume tries reached (${MAX_RESUME_TRIES}), giving up.`);
}

return r;
}

return false;
Expand Down

0 comments on commit 4be1919

Please sign in to comment.