File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,11 @@ class Executor extends Commander {
14
14
15
15
execute ( tempPath , command ) {
16
16
const containerName = uuid . v4 ( ) ;
17
- let timer = setTimeout ( ( ) => {
18
- timer = null ;
19
- execute ( `docker kill ${ containerName } ` , this . cwd ) ;
17
+ let killed = false ;
18
+ const timer = setTimeout ( ( ) => {
19
+ execute ( `docker kill ${ containerName } ` , this . cwd ) . then ( ( ) => {
20
+ killed = true ;
21
+ } ) ;
20
22
} , timeLimit ) ;
21
23
return execute ( [
22
24
`docker run --rm` ,
@@ -30,13 +32,9 @@ class Executor extends Commander {
30
32
'/bin/bash -c' ,
31
33
`"${ command } "` ,
32
34
] . join ( ' ' ) , this . cwd ) . catch ( error => {
33
- if ( timer ) {
34
- clearTimeout ( timer ) ;
35
- } else {
36
- console . error ( 'Time Limit Exceeded' ) ;
37
- }
35
+ if ( killed ) console . error ( 'Time Limit Exceeded' ) ;
38
36
throw error ;
39
- } ) ;
37
+ } ) . finally ( ( ) => clearTimeout ( timer ) ) ;
40
38
}
41
39
42
40
compile ( tempPath ) {
Original file line number Diff line number Diff line change @@ -74,4 +74,4 @@ set_target_properties(tracers
74
74
return { name, content } ;
75
75
} ) ;
76
76
77
- export default builder ;
77
+ export default builder ;
You can’t perform that action at this time.
0 commit comments