Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Fix races around touching state.Group outside of the event loop #589

Merged
merged 1 commit into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions common/frame_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,11 @@ func (fs *FrameSession) onConsoleAPICalled(event *cdpruntime.EventConsoleAPICall
WithTime(event.Timestamp.Time()).
WithField("source", "browser-console-api")

if s := fs.vu.State(); s.Group.Path != "" {
l = l.WithField("group", s.Group.Path)
}
/* accessing the state Group while not on the eventloop is racy
if s := fs.vu.State(); s.Group.Path != "" {
l = l.WithField("group", s.Group.Path)
}
*/
ankur22 marked this conversation as resolved.
Show resolved Hide resolved
inancgumus marked this conversation as resolved.
Show resolved Hide resolved

var parsedObjects []interface{}
for _, robj := range event.Args {
Expand Down Expand Up @@ -688,9 +690,11 @@ func (fs *FrameSession) onLogEntryAdded(event *cdplog.EventEntryAdded) {
WithField("url", event.Entry.URL).
WithField("browser_source", event.Entry.Source.String()).
WithField("line_number", event.Entry.LineNumber)
if s := fs.vu.State(); s.Group.Path != "" {
l = l.WithField("group", s.Group.Path)
}
/* accessing the state Group while not on the eventloop is racy
if s := fs.vu.State(); s.Group.Path != "" {
l = l.WithField("group", s.Group.Path)
}
*/
inancgumus marked this conversation as resolved.
Show resolved Hide resolved
switch event.Entry.Level {
case "info":
l.Info(event.Entry.Text)
Expand Down
6 changes: 0 additions & 6 deletions common/network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ func (m *NetworkManager) emitRequestMetrics(req *Request) {
state := m.vu.State()

tags := state.Tags.GetCurrentValues()
if state.Options.SystemTags.Has(k6metrics.TagGroup) {
tags = tags.With("group", state.Group.Path)
}
if state.Options.SystemTags.Has(k6metrics.TagMethod) {
tags = tags.With("method", req.method)
}
Expand Down Expand Up @@ -216,9 +213,6 @@ func (m *NetworkManager) emitResponseMetrics(resp *Response, req *Request) {
}

tags := state.Tags.GetCurrentValues()
if state.Options.SystemTags.Has(k6metrics.TagGroup) {
tags = tags.With("group", state.Group.Path)
}
if state.Options.SystemTags.Has(k6metrics.TagMethod) {
tags = tags.With("method", req.method)
}
Expand Down