Skip to content

Commit

Permalink
fix(ResumeTask) don't expose retryDelay
Browse files Browse the repository at this point in the history
It's only used internally.
  • Loading branch information
saghul committed Nov 28, 2024
1 parent 39c4422 commit 3dd8fff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
17 changes: 4 additions & 13 deletions modules/xmpp/ResumeTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class ResumeTask {
*/
this._resumeRetryN = 0;

this._retryDelay = undefined;
this._resumeTimeout = undefined;
}

/**
Expand All @@ -39,14 +39,6 @@ export default class ResumeTask {
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.
*/
get retryDelay() {
return this._retryDelay;
}

/**
* Called by {@link XmppConnection} when the connection drops and it's a signal it wants to schedule a reconnect.
*
Expand Down Expand Up @@ -88,14 +80,14 @@ export default class ResumeTask {
// 1st retry: 1.5s - 3s
// 2nd retry: 3s - 9s
// 3rd and next retry: 4.5s - 27s
this._retryDelay = getJitterDelay(
const retryDelay = getJitterDelay(
/* retry */ this._resumeRetryN,
/* minDelay */ this._resumeRetryN * 1500,
3);

logger.info(`Will try to resume the XMPP connection in ${this.retryDelay}ms`);
logger.info(`Will try to resume the XMPP connection in ${retryDelay}ms`);

this._resumeTimeout = setTimeout(() => this._resumeConnection(), this.retryDelay);
this._resumeTimeout = setTimeout(() => this._resumeConnection(), retryDelay);
}

/**
Expand All @@ -109,7 +101,6 @@ export default class ResumeTask {
logger.info('Canceling connection resume task');
clearTimeout(this._resumeTimeout);
this._resumeTimeout = undefined;
this._retryDelay = undefined;
}
}

Expand Down
2 changes: 1 addition & 1 deletion types/hand-crafted/modules/xmpp/ResumeTask.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default class ResumeTask {
constructor( stropheConnection: Strophe.Connection );
retryDelay: () => number | undefined;
retryCount: () => number;
schedule: () => void;
cancel: () => void;
}

0 comments on commit 3dd8fff

Please sign in to comment.