grafana/k6 · error

invalid GRPC Stream's client

Error message

invalid GRPC Stream's client: %w

What it means

Raised in the grpc module's stream constructor when extractClient cannot interpret the first argument as a connected grpc.Client — wrong type, uninitialized client, or a client that failed construction. Thrown via common.Throw.

Solutions

  1. Pass a grpc.Client instance created with new grpc.Client() as the first argument
  2. Ensure the client is fully constructed before instantiating grpc.Stream
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at internal/js/modules/k6/grpc/grpc.go:117 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/718d0e00b619dc7d. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/grpc/grpc.go:117

	mustAddServingStatus("HealthCheckServing", healthpb.HealthCheckResponse_SERVING)
	mustAddServingStatus("HealthCheckNotServing", healthpb.HealthCheckResponse_NOT_SERVING)
	mustAddServingStatus("HealthCheckServiceUnkown", healthpb.HealthCheckResponse_SERVICE_UNKNOWN)
}

// Exports returns the exports of the grpc module.
func (mi *ModuleInstance) Exports() modules.Exports {
	return modules.Exports{
		Named: mi.exports,
	}
}

// stream returns a new stream object
func (mi *ModuleInstance) stream(c sobek.ConstructorCall) *sobek.Object {
	rt := mi.vu.Runtime()

	client, err := extractClient(c.Argument(0), rt)
	if err != nil {
		common.Throw(rt, fmt.Errorf("invalid GRPC Stream's client: %w", err))
	}

	methodName := sanitizeMethodName(c.Argument(1).String())
	methodDescriptor, err := client.getMethodDescriptor(methodName)
	if err != nil {
		common.Throw(rt, fmt.Errorf("invalid GRPC Stream's method: %w", err))
	}

	p, err := newCallParams(mi.vu, c.Argument(2))
	if err != nil {
		common.Throw(rt, fmt.Errorf("invalid GRPC Stream's parameters: %w", err))
	}

	p.SetSystemTags(mi.vu.State(), client.addr, methodName)

	logger := mi.vu.State().Logger.WithField("streamMethod", methodName)

	s := &stream{

View on GitHub (pinned to 01ffac6f24)