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 {
1414
1515 execute ( tempPath , command ) {
1616 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+ } ) ;
2022 } , timeLimit ) ;
2123 return execute ( [
2224 `docker run --rm` ,
@@ -30,13 +32,9 @@ class Executor extends Commander {
3032 '/bin/bash -c' ,
3133 `"${ command } "` ,
3234 ] . 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' ) ;
3836 throw error ;
39- } ) ;
37+ } ) . finally ( ( ) => clearTimeout ( timer ) ) ;
4038 }
4139
4240 compile ( tempPath ) {
Original file line number Diff line number Diff line change @@ -74,4 +74,4 @@ set_target_properties(tracers
7474 return { name, content } ;
7575} ) ;
7676
77- export default builder ;
77+ export default builder ;
You can’t perform that action at this time.
0 commit comments