grafana/k6 · error
converting argument
Error message
converting argument '%v': %w
What it means
Wrap of a json.Marshal failure in the CDP argument converter: convertArgument serializes a Go-side argument (typically a float) to JSON for a Runtime.callFunctionOn invocation. Special values (Infinity, NaN) are handled as UnserializableValue beforehand, so reaching this wrap means the remaining value could not be marshaled — e.g., a float that overflows JSON representation, or an internal type json.Marshal cannot encode. The '%v' shows the offending argument.
Solutions
- Pass finite numeric values to evaluate/handle methods
- Check for computed values that became Inf or NaN through division by zero and handle them explicitly
- Convert exotic types to plain strings or numbers before passing them to browser evaluate calls
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/helpers.go:80 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/219e42a3fa31033c.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/helpers.go:80
case math.Inf(0):
unserVal = "Infinity"
case math.Inf(-1):
unserVal = "-Infinity"
default:
if math.IsNaN(a) {
unserVal = "NaN"
}
}
if unserVal != "" {
return &cdpruntime.CallArgument{
UnserializableValue: cdpruntime.UnserializableValue(unserVal),
}, nil
}
b, err := json.Marshal(a)
if err != nil {
err = fmt.Errorf("converting argument '%v': %w", arg, err)
}
return &cdpruntime.CallArgument{Value: b}, err
case *ElementHandle:
return convertBaseJSHandleTypes(ctx, execCtx, &a.BaseJSHandle)
case *BaseJSHandle:
return convertBaseJSHandleTypes(ctx, execCtx, a)
default:
b, err := json.Marshal(a)
return &cdpruntime.CallArgument{Value: b}, err //nolint:wrapcheck
}
}
func call(
ctx context.Context, fn func(context.Context, chan any, chan error), timeout time.Duration,
) (any, error) {
var (
result anyView on GitHub (pinned to 01ffac6f24)