grafana/k6 · error

converting argument in execution context ID and frame ID

Error message

converting argument %q in execution context ID %d and frame ID %v: %w

What it means

Returned by ExecutionContext.eval when converting a Go argument to a CDP CallArgument fails before calling the injected function. The failing argument, execution context ID and frame ID are included. This is argument marshalling failure: the argument type is not serializable (e.g. unsupported Go value passed through from the script).

Solutions

  1. Pass only serializable arguments: primitives, arrays/maps of primitives, or handles
  2. Convert custom objects to plain JS-serializable structures before passing
  3. Avoid passing functions, channels, or other non-exportable Go values
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/execution_context.go:191 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/4a3fbf8c8bc37ffb. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/execution_context.go:191

		Do(context.Context) (*runtime.RemoteObject, *runtime.ExceptionDetails, error)
	}

	if !opts.forceCallable {
		if !hasSourceURL(js) {
			js += "\n" + suffix
		}

		action = runtime.Evaluate(js).
			WithContextID(e.id).
			WithReturnByValue(opts.returnByValue).
			WithAwaitPromise(true).
			WithUserGesture(true)
	} else {
		var arguments []*runtime.CallArgument
		for _, arg := range args {
			result, err := convertArgument(apiCtx, e, arg)
			if err != nil {
				return nil, fmt.Errorf("converting argument %q "+
					"in execution context ID %d and frame ID %v: %w",
					arg, e.id, e.Frame().ID(), err)
			}
			arguments = append(arguments, result)
		}

		js += "\n" + suffix + "\n"
		action = runtime.CallFunctionOn(js).
			WithArguments(arguments).
			WithExecutionContextID(e.id).
			WithReturnByValue(opts.returnByValue).
			WithAwaitPromise(true).
			WithUserGesture(true)
	}

	var (
		remoteObject     *runtime.RemoteObject
		exceptionDetails *runtime.ExceptionDetails

View on GitHub (pinned to 01ffac6f24)