Skip to content

Commit

Permalink
Fix race condition activating VUs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Feb 24, 2021
1 parent 8961df9 commit baa0e94
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions js/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,10 @@ func (u *VU) Activate(params *lib.VUActivationParams) lib.ActiveVU {
u.state.Tags["scenario"] = params.Scenario
}

params.RunContext = common.WithRuntime(params.RunContext, u.Runtime)
params.RunContext = lib.WithState(params.RunContext, u.state)
*u.Context = params.RunContext
ctx := common.WithRuntime(params.RunContext, u.Runtime)
ctx = lib.WithState(ctx, u.state)
params.RunContext = ctx
*u.Context = ctx
u.state.ScenarioName = params.Scenario
if params.GetScenarioVUID != nil {
if _, ok := u.state.GetScenarioVUID(); !ok {
Expand All @@ -613,7 +614,7 @@ func (u *VU) Activate(params *lib.VUActivationParams) lib.ActiveVU {

go func() {
// Wait for the run context to be over
<-params.RunContext.Done()
<-ctx.Done()
// Interrupt the JS runtime
u.Runtime.Interrupt(context.Canceled)
// Wait for the VU to stop running, if it was, and prevent it from
Expand Down

0 comments on commit baa0e94

Please sign in to comment.