summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-08-18 01:05:04 -0500
committerMike Greiling <mike@pixelcog.com>2017-08-18 03:01:23 -0500
commitd4cb1ec9e96be4154d97d8b20c7b5264e8c5ae8b (patch)
tree8ffccf239c0cc7f8656845025c22db9579c9fd92 /app/assets/javascripts/lib
parent5a332c5974dcea7177cd3ad89c494fa9ba62880f (diff)
downloadgitlab-ce-d4cb1ec9e96be4154d97d8b20c7b5264e8c5ae8b.tar.gz
fix unnecessarily long gl.utils.backOff test36648-fix-backoff-util-tests
Diffstat (limited to 'app/assets/javascripts/lib')
-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'));