Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
aa1f7de9
Commit
aa1f7de9
authored
Feb 27, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves backoff algo with maxInterval between requests
parent
8b855eaf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
app/assets/javascripts/lib/utils/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 @
aa1f7de9
...
@@ -329,17 +329,18 @@
...
@@ -329,17 +329,18 @@
* ```
* ```
*/
*/
w.gl.utils.backOff = (fn, timeout = 60000) => {
w.gl.utils.backOff = (fn, timeout = 60000) => {
const maxInterval = 32000;
let nextInterval = 2000;
let nextInterval = 2000;
const startTime =
(+new Date()
);
const startTime =
Date.now(
);
return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
const stop = arg => ((arg instanceof Error) ? reject(arg) : resolve(arg));
const stop = arg => ((arg instanceof Error) ? reject(arg) : resolve(arg));
const next = () => {
const next = () => {
if (
new Date().getTime
() - startTime < timeout) {
if (
Date.now
() - startTime < timeout) {
setTimeout(fn.bind(null, next, stop), nextInterval);
setTimeout(fn.bind(null, next, stop), nextInterval);
nextInterval
*= 2
;
nextInterval
= Math.min(nextInterval + nextInterval, maxInterval)
;
} else {
} else {
reject(new Error('BACKOFF_TIMEOUT'));
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