summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-08-18 10:05:11 +0000
committerPhil Hughes <me@iamphill.com>2017-08-18 10:05:11 +0000
commit63812b2fb2dc53f94ab452761553e8cc5f046f2c (patch)
tree5ff9efc03c2f7b291ac8a7c93b99a1b378d5003c /app/assets/javascripts
parent97fcbaf5d98c633cc115982223a36bf349a2ab08 (diff)
parentd4cb1ec9e96be4154d97d8b20c7b5264e8c5ae8b (diff)
downloadgitlab-ce-63812b2fb2dc53f94ab452761553e8cc5f046f2c.tar.gz
Merge branch '36648-fix-backoff-util-tests' into 'master'
Fix unnecessarily long gl.utils.backOff test Closes #36648 See merge request !13651
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/lib/utils/common_utils.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js
index e916724b666..b8f4f4eaba3 100644
--- a/app/assets/javascripts/lib/utils/common_utils.js
+++ b/app/assets/javascripts/lib/utils/common_utils.js
@@ -378,15 +378,15 @@
w.gl.utils.backOff = (fn, timeout = 60000) => {
const maxInterval = 32000;
let nextInterval = 2000;
-
- const startTime = Date.now();
+ let timeElapsed = 0;
return new Promise((resolve, reject) => {
const stop = arg => ((arg instanceof Error) ? reject(arg) : resolve(arg));
const next = () => {
- if (Date.now() - startTime < timeout) {
- setTimeout(fn.bind(null, next, stop), nextInterval);
+ if (timeElapsed < timeout) {
+ setTimeout(() => fn(next, stop), nextInterval);
+ timeElapsed += nextInterval;
nextInterval = Math.min(nextInterval + nextInterval, maxInterval);
} else {
reject(new Error('BACKOFF_TIMEOUT'));