Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ResumeTask) don't expose retryDelay #2603

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading