diff options
Diffstat (limited to 'app/assets/javascripts/lib/utils/common_utils.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 8 |
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')); |