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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
2ab322eb
Commit
2ab322eb
authored
Feb 15, 2017
by
Takuya Noguchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace setInterval with setTimeout to prevent highly frequent requests
parent
7d15f36b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
13 deletions
+24
-13
app/assets/javascripts/build.js
app/assets/javascripts/build.js
+20
-13
changelogs/unreleased/28212-avoid-dos-on-build-trace.yml
changelogs/unreleased/28212-avoid-dos-on-build-trace.yml
+4
-0
No files found.
app/assets/javascripts/build.js
View file @
2ab322eb
...
...
@@ -7,7 +7,7 @@
var
DOWN_BUILD_TRACE
=
'
#down-build-trace
'
;
this
.
Build
=
(
function
()
{
Build
.
interval
=
null
;
Build
.
timeout
=
null
;
Build
.
state
=
null
;
...
...
@@ -31,7 +31,7 @@
this
.
$scrollBottomBtn
=
$
(
'
#scroll-bottom
'
);
this
.
$buildRefreshAnimation
=
$
(
'
.js-build-refresh
'
);
clear
Interval
(
Build
.
interval
);
clear
Timeout
(
Build
.
timeout
);
// Init breakpoint checker
this
.
bp
=
Breakpoints
.
get
();
...
...
@@ -52,17 +52,7 @@
this
.
getInitialBuildTrace
();
this
.
initScrollButtonAffix
();
}
if
(
this
.
buildStatus
===
"
running
"
||
this
.
buildStatus
===
"
pending
"
)
{
Build
.
interval
=
setInterval
((
function
(
_this
)
{
// Check for new build output if user still watching build page
// Only valid for runnig build when output changes during time
return
function
()
{
if
(
_this
.
location
()
===
_this
.
pageUrl
)
{
return
_this
.
getBuildTrace
();
}
};
})(
this
),
4000
);
}
this
.
invokeBuildTrace
();
}
Build
.
prototype
.
initSidebar
=
function
()
{
...
...
@@ -75,6 +65,22 @@
return
window
.
location
.
href
.
split
(
"
#
"
)[
0
];
};
Build
.
prototype
.
invokeBuildTrace
=
function
()
{
var
continueRefreshStatuses
=
[
'
running
'
,
'
pending
'
];
// Continue to update build trace when build is running or pending
if
(
continueRefreshStatuses
.
indexOf
(
this
.
buildStatus
)
!==
-
1
)
{
// Check for new build output if user still watching build page
// Only valid for runnig build when output changes during time
Build
.
timeout
=
setTimeout
((
function
(
_this
)
{
return
function
()
{
if
(
_this
.
location
()
===
_this
.
pageUrl
)
{
return
_this
.
getBuildTrace
();
}
};
})(
this
),
4000
);
}
};
Build
.
prototype
.
getInitialBuildTrace
=
function
()
{
var
removeRefreshStatuses
=
[
'
success
'
,
'
failed
'
,
'
canceled
'
,
'
skipped
'
];
...
...
@@ -105,6 +111,7 @@
if
(
log
.
state
)
{
_this
.
state
=
log
.
state
;
}
_this
.
invokeBuildTrace
();
if
(
log
.
status
===
"
running
"
)
{
if
(
log
.
append
)
{
$
(
'
.js-build-output
'
).
append
(
log
.
html
);
...
...
changelogs/unreleased/28212-avoid-dos-on-build-trace.yml
0 → 100644
View file @
2ab322eb
---
title
:
Replace setInterval with setTimeout to prevent highly frequent requests
merge_request
:
9271
author
:
Takuya Noguchi
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