@@ -46,9 +46,7 @@ module.exports = {
4646 this . eventForParallelExecution = event ;
4747 }
4848 const data = this . _findStep ( state , stateName ) ;
49- if ( ! data || data instanceof Promise ) {
50- return data ;
51- }
49+ if ( ! data || data instanceof Promise ) { return data ; }
5250 if ( data . choice ) {
5351 return this . _runChoice ( data , event ) ;
5452 } else {
@@ -58,9 +56,7 @@ module.exports = {
5856
5957 _findStep ( currentState , currentStateName ) {
6058 // it means end of states
61- if ( ! currentState ) {
62- return ;
63- }
59+ if ( ! currentState ) { return ; }
6460 this . currentState = currentState ;
6561 return this . _switcherByType ( currentState , currentStateName ) ;
6662 } ,
@@ -83,12 +79,15 @@ module.exports = {
8379 f : ( ) => require ( path . join ( process . cwd ( ) , this . variables [ currentStateName ] . filePath ) ) [ this . variables [ currentStateName ] . handler ]
8480 } ;
8581 case 'Parallel' : // look through branches and push all of them
82+ this . eventParallelResult = [ ] ;
8683 _ . forEach ( currentState . Branches , ( branch ) => {
8784 this . parallelBranch = branch ;
8885 return this . process ( branch . States [ branch . StartAt ] , branch . StartAt , this . eventForParallelExecution ) ;
8986 } ) ;
87+ this . process ( this . states [ currentState . Next ] , currentState . Next , this . eventParallelResult ) ;
9088 delete this . parallelBranch ;
91- return this . process ( this . states [ currentState . Next ] , currentState . Next ) ;
89+ delete this . eventParallelResult ;
90+ return ;
9291 case 'Choice' :
9392 //push all choices. but need to store information like
9493 // 1) on which variable need to look: ${variable}
@@ -221,6 +220,7 @@ module.exports = {
221220 let state = this . states ;
222221 if ( this . parallelBranch && this . parallelBranch . States ) {
223222 state = this . parallelBranch . States ;
223+ if ( ! this . currentState . Next ) this . eventParallelResult . push ( result ) ; //it means the end of execution of branch
224224 }
225225 this . process ( state [ this . currentState . Next ] , this . currentState . Next , result ) ;
226226 } ) ;
0 commit comments