grafana/k6 · error
failed to create a new parser; reason
Error message
failed to create a new parser; reason: %w
What it means
Raised in csv.Parse when NewReaderFrom fails to construct the CSV reader over the opened fs.File handle with the resolved parser options — '%w' carries the construction error, typically an unsupported charset/encoding or an unusable file mode (the file must be readable and seekable). This is a setup failure: no rows have been read yet and no shared array is created.
Solutions
- Verify the file was opened in 'r' (read) mode
- Use a supported charset in the options
- Check the wrapped error for the exact reader-construction cause
- Confirm the underlying file is a regular seekable file, not a stream
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/experimental/csv/module.go:118 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/c078fb307d71be5a.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/experimental/csv/module.go:118
// 1. Make sure the Sobek object is a fs.File (Sobek operation)
var fileObj fs.File
if err := mi.vu.Runtime().ExportTo(file, &fileObj); err != nil {
return nil, fmt.Errorf("first argument expected to be a fs.File instance, got %T instead", file)
}
parserOptions := newDefaultParserOptions()
if options != nil {
var err error
parserOptions, err = newParserOptionsFrom(options.ToObject(rt))
if err != nil {
return nil, fmt.Errorf("failed to interpret the provided Parser options; reason: %w", err)
}
}
r, err := NewReaderFrom(fileObj.ReadSeekStater, parserOptions)
if err != nil {
return nil, fmt.Errorf("failed to create a new parser; reason: %w", err)
}
underlyingSharedArrayName, err := buildSharedArrayName(fileObj, parserOptions)
if err != nil {
return nil, fmt.Errorf("failed to derive shared array name; reason: %w", err)
}
callback := mi.vu.RegisterCallback()
promise, resolve, reject := rt.NewPromise()
go func() {
// Because we rely on the data module to create the shared array, we need to
// make sure that the data module is initialized before we can proceed, and that we don't instantiate
// it multiple times.
//
// As such we hold a single instance of it in the RootModule, and we use it to create the shared array.
fn, err := mi.dataModuleInstance.NewSharedArrayFrom(mi.vu.Runtime(), underlyingSharedArrayName, r)
if err != nil {View on GitHub (pinned to 01ffac6f24)