grafana/k6 · error
invalid GRPC Stream's method: %w
Error message
invalid GRPC Stream's method: %w
What it means
The method name passed to new grpc.Stream() must resolve to a protobuf MethodDescriptor known by that client. client.getMethodDescriptor() only knows services loaded in init via client.load(importPaths, protoFiles) or discovered through server reflection (client.connect(addr, { reflect: true })). An unknown service/method name, a missing or unloaded proto, or a reflection lookup failure produces this error.
Source
Thrown at internal/js/modules/k6/grpc/grpc.go:123
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{
vu: mi.vu,
client: client,
methodDescriptor: methodDescriptor,
method: methodName,
logger: logger,
View on GitHub (pinned to 93accf6570)
Solutions
- Open the .proto and copy the method path exactly as package.Service/Method; ensure client.load() runs in init code and its import path resolves the proto's package declaration
- If using server reflection, connect with { reflect: true } and confirm the server actually implements the reflection service
- Check the results of client.load() and the connect() call for earlier failures before constructing the Stream
Example fix
// before
client.connect('localhost:8080');
const stream = new grpc.Stream(client, '/testing.TestService/ServerStream');
// after
client.load(['protobufs'], 'service.proto'); // defines package testing
client.connect('localhost:8080');
const stream = new grpc.Stream(client, '/testing.TestService/ServerStream'); Defensive patterns
Strategy: try-catch
Validate before calling
// No public JS API lists loaded methods; at minimum assert the proto loaded
const loaded = client.load(['protobufs'], 'service.proto');
if (!loaded || loaded.length === 0) {
throw new Error('service.proto failed to load; refusing to build a stream');
} Try / catch
let stream;
try {
stream = new grpc.Stream(client, METHOD);
} catch (err) {
if (String(err.message).includes("invalid GRPC Stream's method")) {
console.error(`method ${METHOD} unknown: check client.load() paths or enable server reflection with reflect: true`);
}
throw err;
} Prevention
- Copy method paths verbatim from the .proto (package.Service/Method)
- Call client.load() once in init code and check its result before handleSummary or default export runs
- If relying on reflection, verify the server implements the reflection service in the target environment
When it happens
Trigger: client.load() not called (or called with a wrong import path / proto file) before new grpc.Stream; a typo in the fully qualified name like '/grpc.testing.TestService/StreamingOutputCall'; relying on reflection while the server does not implement the gRPC reflection service or reflect:true was not passed to connect().
Common situations: Method renamed or moved in a new .proto revision; scripts copied from another service with a different package name; reflection enabled in dev but disabled in the load-test environment; missing leading slash or wrong package qualification.
Related errors
- can't convert method info: %w
- invalid GRPC Stream's client: %w
- invalid GRPC Stream's parameters: %w
- unknown GRPC stream's event type: %s
- invalid reflect value: '%#v', it needs to be boolean
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/4edefc3508d71683.
Report an issue: GitHub.