Skip to content

Commit

Permalink
[core] delete run_number only after all STOP_ACTIVITY hooks are called
Browse files Browse the repository at this point in the history
  • Loading branch information
knopers8 authored and teo committed Jul 15, 2024
1 parent 4833f42 commit 7eeb30b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,6 @@ func newEnvironment(userVars map[string]string, newId uid.ID) (env *Environment,

the.EventWriterWithTopic(topic.Run).WriteEventWithTimestamp(runEvent, runEndCompletionTime)

// If the event is STOP_ACTIVITY, we remove the active run number after all hooks are done.
env.workflow.GetVars().Set("last_run_number", strconv.Itoa(int(env.currentRunNumber)))
env.currentRunNumber = 0
env.workflow.GetVars().Del("run_number")
env.workflow.GetVars().Del("runNumber")
// Ensure the auto stop timer is stopped (important for stop transitions NOT triggered by the timer itself)
env.invalidateAutoStopTransition()
} else if e.Event == "GO_ERROR" {
Expand Down Expand Up @@ -608,6 +603,15 @@ func newEnvironment(userVars map[string]string, newId uid.ID) (env *Environment,
if e.Err != nil {
errorMsg = e.Err.Error()
}

if e.Event == "STOP_ACTIVITY" {
// If the event is STOP_ACTIVITY, we remove the active run number after all hooks are done.
env.workflow.GetVars().Set("last_run_number", strconv.Itoa(int(env.currentRunNumber)))
env.currentRunNumber = 0
env.workflow.GetVars().Del("run_number")
env.workflow.GetVars().Del("runNumber")
}

// publish transition step complete event
the.EventWriterWithTopic(topic.Environment).WriteEvent(&pb.Ev_EnvironmentEvent{
EnvironmentId: env.id.String(),
Expand Down

0 comments on commit 7eeb30b

Please sign in to comment.