@@ -614,14 +614,6 @@ func newEnvironment(userVars map[string]string, newId uid.ID) (env *Environment,
614614 errorMsg = e .Err .Error ()
615615 }
616616
617- if e .Event == "STOP_ACTIVITY" {
618- // If the event is STOP_ACTIVITY, we remove the active run number after all hooks are done.
619- env .workflow .GetVars ().Set ("last_run_number" , strconv .Itoa (int (env .currentRunNumber )))
620- env .currentRunNumber = 0
621- env .workflow .GetVars ().Del ("run_number" )
622- env .workflow .GetVars ().Del ("runNumber" )
623- }
624-
625617 // publish transition step complete event
626618 the .EventWriterWithTopic (topic .Environment ).WriteEvent (& pb.Ev_EnvironmentEvent {
627619 EnvironmentId : env .id .String (),
@@ -634,6 +626,16 @@ func newEnvironment(userVars map[string]string, newId uid.ID) (env *Environment,
634626 LastRequestUser : env .GetLastRequestUser (),
635627 WorkflowTemplateInfo : env .GetWorkflowInfo (),
636628 })
629+
630+ if e .Event == "STOP_ACTIVITY" || e .Event == "GO_ERROR" {
631+ // If the event is STOP_ACTIVITY or GO_ERROR, we remove the active run number after all hooks are done.
632+ if env .currentRunNumber != 0 {
633+ env .workflow .GetVars ().Set ("last_run_number" , strconv .Itoa (int (env .currentRunNumber )))
634+ }
635+ env .currentRunNumber = 0
636+ env .workflow .GetVars ().Del ("run_number" )
637+ env .workflow .GetVars ().Del ("runNumber" )
638+ }
637639 },
638640 },
639641 )
0 commit comments