@@ -472,9 +472,6 @@ export class TransactionOrchestrator extends EventEmitter {
472472 )
473473 }
474474
475- const flow = transaction . getFlow ( )
476- const options = TransactionOrchestrator . getWorkflowOptions ( flow . modelId )
477-
478475 if ( ! hasStepTimedOut ) {
479476 step . changeStatus ( TransactionStepStatus . OK )
480477 }
@@ -485,8 +482,15 @@ export class TransactionOrchestrator extends EventEmitter {
485482 step . changeState ( TransactionStepState . DONE )
486483 }
487484
488- if ( step . definition . async || options ?. storeExecution ) {
485+ let shouldEmit = true
486+ try {
489487 await transaction . saveCheckpoint ( )
488+ } catch ( error ) {
489+ if ( SkipExecutionError . isSkipExecutionError ( error ) ) {
490+ shouldEmit = false
491+ } else {
492+ throw error
493+ }
490494 }
491495
492496 const cleaningUp : Promise < unknown > [ ] = [ ]
@@ -499,10 +503,12 @@ export class TransactionOrchestrator extends EventEmitter {
499503
500504 await promiseAll ( cleaningUp )
501505
502- const eventName = step . isCompensating ( )
503- ? DistributedTransactionEvent . COMPENSATE_STEP_SUCCESS
504- : DistributedTransactionEvent . STEP_SUCCESS
505- transaction . emit ( eventName , { step, transaction } )
506+ if ( shouldEmit ) {
507+ const eventName = step . isCompensating ( )
508+ ? DistributedTransactionEvent . COMPENSATE_STEP_SUCCESS
509+ : DistributedTransactionEvent . STEP_SUCCESS
510+ transaction . emit ( eventName , { step, transaction } )
511+ }
506512 }
507513
508514 private static async skipStep (
@@ -605,7 +611,6 @@ export class TransactionOrchestrator extends EventEmitter {
605611 }
606612
607613 const flow = transaction . getFlow ( )
608- const options = TransactionOrchestrator . getWorkflowOptions ( flow . modelId )
609614
610615 const cleaningUp : Promise < unknown > [ ] = [ ]
611616
@@ -654,8 +659,15 @@ export class TransactionOrchestrator extends EventEmitter {
654659 }
655660 }
656661
657- if ( step . definition . async || options ?. storeExecution ) {
662+ let shouldEmit = true
663+ try {
658664 await transaction . saveCheckpoint ( )
665+ } catch ( error ) {
666+ if ( SkipExecutionError . isSkipExecutionError ( error ) ) {
667+ shouldEmit = false
668+ } else {
669+ throw error
670+ }
659671 }
660672
661673 if ( step . hasRetryScheduled ( ) ) {
@@ -664,10 +676,12 @@ export class TransactionOrchestrator extends EventEmitter {
664676
665677 await promiseAll ( cleaningUp )
666678
667- const eventName = step . isCompensating ( )
668- ? DistributedTransactionEvent . COMPENSATE_STEP_FAILURE
669- : DistributedTransactionEvent . STEP_FAILURE
670- transaction . emit ( eventName , { step, transaction } )
679+ if ( shouldEmit ) {
680+ const eventName = step . isCompensating ( )
681+ ? DistributedTransactionEvent . COMPENSATE_STEP_FAILURE
682+ : DistributedTransactionEvent . STEP_FAILURE
683+ transaction . emit ( eventName , { step, transaction } )
684+ }
671685 }
672686
673687 private async executeNext (
@@ -696,17 +710,27 @@ export class TransactionOrchestrator extends EventEmitter {
696710 continue
697711 }
698712
699- console . log ( "Remaining STEPS" , nextSteps . remaining )
713+ console . log (
714+ "Remaining STEPS" ,
715+ transaction . getFlow ( ) . modelId ,
716+ nextSteps . remaining ,
717+ nextSteps . next . map ( ( step ) => step . id ) ,
718+ nextSteps . current ?? "nothing"
719+ )
700720
701721 if ( nextSteps . remaining === 0 ) {
702722 if ( transaction . hasTimeout ( ) ) {
703723 void transaction . clearTransactionTimeout ( )
704724 }
705725
706- await transaction . saveCheckpoint ( )
726+ // let shouldStop = false
727+ // await transaction.saveCheckpoint()
707728
708729 console . log ( "FINISH" , transaction . getFlow ( ) . transactionId )
709730 this . emit ( DistributedTransactionEvent . FINISH , { transaction } )
731+ // if (shouldStop) {
732+ // return
733+ // }
710734 }
711735
712736 let hasSyncSteps = false
@@ -827,14 +851,15 @@ export class TransactionOrchestrator extends EventEmitter {
827851 ] as Parameters < TransactionStepHandler >
828852
829853 if ( ! isAsync ) {
830- try {
831- await transaction . saveCheckpoint ( )
832- } catch ( error ) {
833- if ( SkipExecutionError . isSkipExecutionError ( error ) ) {
834- continueExecution = false
835- continue
836- }
837- }
854+ // try {
855+ // await transaction.saveCheckpoint()
856+ // } catch (error) {
857+ // if (SkipExecutionError.isSkipExecutionError(error)) {
858+ // await transaction.clearStepTimeout(step)
859+ // continueExecution = false
860+ // continue
861+ // }
862+ // }
838863
839864 hasSyncSteps = true
840865
@@ -873,8 +898,8 @@ export class TransactionOrchestrator extends EventEmitter {
873898 )
874899 } )
875900 . catch ( async ( error ) => {
876- console . log ( "ON Failure SYNC" , error )
877901 if ( SkipExecutionError . isSkipExecutionError ( error ) ) {
902+ await transaction . clearStepTimeout ( step )
878903 continueExecution = false
879904 return
880905 }
@@ -963,6 +988,7 @@ export class TransactionOrchestrator extends EventEmitter {
963988 console . log ( "ON Failure" , error )
964989
965990 if ( SkipExecutionError . isSkipExecutionError ( error ) ) {
991+ await transaction . clearStepTimeout ( step )
966992 continueExecution = false
967993 return
968994 }
0 commit comments