BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ead12a90
Commit
ead12a90
authored
Feb 27, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'improve-backoff-algo' into 'master'
Improves backoff algo with maxInterval between requests See merge request !9548
parents
9c3d21e7
aa1f7de9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
common_utils.js.es6
app/assets/javascripts/lib/utils/common_utils.js.es6
+4
-3
No files found.
app/assets/javascripts/lib/utils/common_utils.js.es6
View file @
ead12a90
...
...
@@ -329,17 +329,18 @@
* ```
*/
w.gl.utils.backOff = (fn, timeout = 60000) => {
const maxInterval = 32000;
let nextInterval = 2000;
const startTime =
(+new Date()
);
const startTime =
Date.now(
);
return new Promise((resolve, reject) => {
const stop = arg => ((arg instanceof Error) ? reject(arg) : resolve(arg));
const next = () => {
if (
new Date().getTime
() - startTime < timeout) {
if (
Date.now
() - startTime < timeout) {
setTimeout(fn.bind(null, next, stop), nextInterval);
nextInterval
*= 2
;
nextInterval
= Math.min(nextInterval + nextInterval, maxInterval)
;
} else {
reject(new Error('BACKOFF_TIMEOUT'));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment