mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
minor tweak to tryForTime
This commit is contained in:
parent
94adb569b5
commit
1cf47d4e1d
1 changed files with 4 additions and 4 deletions
|
@ -85,6 +85,7 @@ define(function (require) {
|
|||
tryForTime: function tryForTime(timeout, block) {
|
||||
var self = this;
|
||||
var start = Date.now();
|
||||
var retryDelay = 500;
|
||||
var lastTry = 0;
|
||||
|
||||
function attempt() {
|
||||
|
@ -97,13 +98,12 @@ define(function (require) {
|
|||
return Promise
|
||||
.try(block)
|
||||
.then(function tryForTimeSuccess() {
|
||||
self.debug('tryForTime success in about ' + (lastTry - start) + ' milliseconds');
|
||||
self.debug('tryForTime success in about ' + (lastTry - start) + ' ms');
|
||||
return (lastTry - start);
|
||||
})
|
||||
.catch(function tryForTimeCatch(err) {
|
||||
self.debug('failed with "' + err.message + '"');
|
||||
self.debug('trying again in 1/2 second');
|
||||
return Promise.delay(500).then(attempt);
|
||||
self.debug('tryForTime failure, retry in ' + retryDelay + 'ms - ' + err.message);
|
||||
return Promise.delay(retryDelay).then(attempt);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue