grafana/k6 · error
failed to marshal record; reason: %w
Error message
failed to marshal record; reason: %w
What it means
Error "failed to marshal record; reason: %w" thrown in grafana/k6.
Source
Thrown at internal/js/modules/k6/data/data.go:148
// The builder function is passed to loadOrStore, which ensures it is only
// executed once for a given name. This guarantees the underlying data is
// initialized exactly once, even if multiple VUs call this function concurrently
// with the same name.
builder := func() (sharedArray, error) {
var arr []string
for {
record, err := r.Read()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
return sharedArray{}, fmt.Errorf("failed to read record; reason: %w", err)
}
marshaled, err := json.Marshal(record)
if err != nil {
return sharedArray{}, fmt.Errorf("failed to marshal record; reason: %w", err)
}
arr = append(arr, string(marshaled))
}
return sharedArray{arr: arr}, nil
}
array, err := d.shared.loadOrStore(name, builder)
if err != nil {
return nil, err
}
return func() *sobek.Object {
return array.wrap(rt).ToObject(rt)
}, nil
}
View on GitHub (pinned to 93accf6570)
When it happens
Trigger: Thrown at internal/js/modules/k6/data/data.go:148 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/2c0e6bb3e2590a66.
Report an issue: GitHub.