mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-23 10:29:11 +00:00
CommentController: Delay polling on error
Use exponential backoff. Bug: T362814 Change-Id: I436a700de3b89abbfa1f991bcf6dc7aa52008cbd
This commit is contained in:
parent
b8a28d6cfc
commit
1bfd97580e
|
@ -228,7 +228,9 @@ CommentController.prototype.onVisibilityChange = function () {
|
|||
}
|
||||
};
|
||||
|
||||
CommentController.prototype.startPoll = function () {
|
||||
CommentController.prototype.startPoll = function ( nextDelay ) {
|
||||
nextDelay = nextDelay || 5000;
|
||||
|
||||
var threadItemId = this.threadItem.id;
|
||||
var subscribableHeadingId = this.threadItem.getSubscribableHeading().id;
|
||||
|
||||
|
@ -268,11 +270,18 @@ CommentController.prototype.startPoll = function () {
|
|||
}
|
||||
|
||||
this.oldId = result.torevid;
|
||||
nextDelay = 5000;
|
||||
}, () => {
|
||||
// Wait longer next time in case of error
|
||||
nextDelay = nextDelay * 1.5;
|
||||
} ).always( () => {
|
||||
if ( this.isTornDown ) {
|
||||
return;
|
||||
}
|
||||
this.pollTimeout = setTimeout( this.startPoll.bind( this ), 5000 );
|
||||
// Stop polling after too many errors
|
||||
if ( nextDelay < 1000 * 60 * 60 ) {
|
||||
this.pollTimeout = setTimeout( this.startPoll.bind( this, nextDelay ), nextDelay );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue