grafana/k6 · error

invalid GRPC's client.invoke() parameters

Error message

invalid GRPC's client.invoke() parameters: %w

What it means

Raised in buildInvokeRequest when newCallParams cannot interpret the params argument of client.invoke — a bad value for metadata, tags, timeout, or an unknown key; the wrapped error identifies the exact problem.

Solutions

  1. Follow the wrapped error to the bad invoke option
  2. Use a plain object with known keys: metadata, tags, timeout, discardResponseMessage
  3. Pass timeout as a duration string like '5s' or milliseconds
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/grpc/client.go:371 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/ddd66a082f8ed3cb. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/grpc/client.go:402

		return grpcReq, common.NewInitContextError("invoking RPC methods in the init context is not supported")
	}
	if c.conn == nil {
		return grpcReq, errors.New("no gRPC connection, you must call connect first")
	}
	if method == "" {
		return grpcReq, errors.New("method to invoke cannot be empty")
	}
	if method[0] != '/' {
		method = "/" + method
	}
	methodDesc := c.mds[method]
	if methodDesc == nil {
		return grpcReq, fmt.Errorf("method %q not found in file descriptors", method)
	}

	p, err := newCallParams(c.vu, params)
	if err != nil {
		return grpcReq, fmt.Errorf("invalid GRPC's client.invoke() parameters: %w", err)
	}

	// k6 GRPC Invoke's default timeout is 2 minutes
	if p.Timeout == time.Duration(0) {
		p.Timeout = 2 * time.Minute
	}

	if req == nil {
		return grpcReq, errors.New("request cannot be nil")
	}

	object := req.ToObject(c.vu.Runtime())

	var stack []*sobek.Object
	normalized, err := normalizeNumberStrings(object, c.vu.Runtime(), stack)
	if err != nil {
		return grpcReq, fmt.Errorf("unable to normalize number strings: %w", err)
	}

View on GitHub (pinned to 8d06114777)