diff --git a/go.mod b/go.mod index bf44a38bfa5..f695973ab7e 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible github.com/golang/protobuf v1.5.3 github.com/gorilla/websocket v1.5.0 - github.com/grafana/xk6-browser v1.0.1 + github.com/grafana/xk6-browser v1.0.2 github.com/grafana/xk6-grpc v0.1.3-0.20230717090346-fb49221e0ce1 github.com/grafana/xk6-output-prometheus-remote v0.2.3 github.com/grafana/xk6-redis v0.1.1 diff --git a/go.sum b/go.sum index 077f4381ed5..52bd36a6679 100644 --- a/go.sum +++ b/go.sum @@ -183,8 +183,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grafana/xk6-browser v1.0.1 h1:/GvMHhDMbNCEuu6ml/AIaQNtHOpj06GpKfgQJpNzPIg= -github.com/grafana/xk6-browser v1.0.1/go.mod h1:Ck8IWES3Emu4CMKktQ/oD7l/JFj/1ESnDIbQGpfaoYA= +github.com/grafana/xk6-browser v1.0.2 h1:B9ll8xLH68hfCBy3sTzhmksCxwgJBIcqgPeX3mht6jM= +github.com/grafana/xk6-browser v1.0.2/go.mod h1:LV/ECGBCN3vRN/A4St+Ep9JUpbKJuRsj+6TBihQptGw= github.com/grafana/xk6-grpc v0.1.3-0.20230717090346-fb49221e0ce1 h1:SdMihJN+fkH6cO/1NeAnVxSVOnJ3ZkZ1v7FJnrcqhog= github.com/grafana/xk6-grpc v0.1.3-0.20230717090346-fb49221e0ce1/go.mod h1:iq6qHN64XgAEmDHKf0OXZ4mvoqF4Udr22fiCIXNpXA0= github.com/grafana/xk6-output-prometheus-remote v0.2.3 h1:ta4wFrO85+29H0papAbeMCavHrBuHDZ4bdKC1Zv8zlo= diff --git a/vendor/github.com/grafana/xk6-browser/browser/registry.go b/vendor/github.com/grafana/xk6-browser/browser/registry.go index 511e26544d7..b21e29093bc 100644 --- a/vendor/github.com/grafana/xk6-browser/browser/registry.go +++ b/vendor/github.com/grafana/xk6-browser/browser/registry.go @@ -230,10 +230,9 @@ func newBrowserRegistry(vu k6modules.VU, remote *remoteRegistry, pids *pidRegist func (r *browserRegistry) handleIterEvents(eventsCh <-chan *k6event.Event, unsubscribeFn func()) { var ( - ok bool - data k6event.IterData - ctx = context.Background() - vuCtx = k6ext.WithVU(r.vu.Context(), r.vu) + ok bool + data k6event.IterData + ctx = context.Background() ) for e := range eventsCh { @@ -251,6 +250,12 @@ func (r *browserRegistry) handleIterEvents(eventsCh <-chan *k6event.Event, unsub return } + // The context in the VU is not thread safe. It can + // be safely accessed during an iteration but not + // before one is started. This is why it is being + // accessed and used here. + vuCtx := k6ext.WithVU(r.vu.Context(), r.vu) + if data, ok = e.Data.(k6event.IterData); !ok { e.Done() k6ext.Abort(vuCtx, "unexpected iteration event data format: %v", e.Data) diff --git a/vendor/modules.txt b/vendor/modules.txt index a3b692f6c54..5ae9d4a175c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -150,7 +150,7 @@ github.com/google/uuid # github.com/gorilla/websocket v1.5.0 ## explicit; go 1.12 github.com/gorilla/websocket -# github.com/grafana/xk6-browser v1.0.1 +# github.com/grafana/xk6-browser v1.0.2 ## explicit; go 1.19 github.com/grafana/xk6-browser/api github.com/grafana/xk6-browser/browser