{"record":{"id":"4edefc3508d71683","repo":"grafana/k6","slug":"invalid-grpc-stream-s-method-w","errorCode":null,"errorMessage":"invalid GRPC Stream's method: %w","messagePattern":"invalid GRPC Stream's method: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/grpc/grpc.go","lineNumber":123,"sourceCode":"func (mi *ModuleInstance) Exports() modules.Exports {\n\treturn modules.Exports{\n\t\tNamed: mi.exports,\n\t}\n}\n\n// stream returns a new stream object\nfunc (mi *ModuleInstance) stream(c sobek.ConstructorCall) *sobek.Object {\n\trt := mi.vu.Runtime()\n\n\tclient, err := extractClient(c.Argument(0), rt)\n\tif err != nil {\n\t\tcommon.Throw(rt, fmt.Errorf(\"invalid GRPC Stream's client: %w\", err))\n\t}\n\n\tmethodName := sanitizeMethodName(c.Argument(1).String())\n\tmethodDescriptor, err := client.getMethodDescriptor(methodName)\n\tif err != nil {\n\t\tcommon.Throw(rt, fmt.Errorf(\"invalid GRPC Stream's method: %w\", err))\n\t}\n\n\tp, err := newCallParams(mi.vu, c.Argument(2))\n\tif err != nil {\n\t\tcommon.Throw(rt, fmt.Errorf(\"invalid GRPC Stream's parameters: %w\", err))\n\t}\n\n\tp.SetSystemTags(mi.vu.State(), client.addr, methodName)\n\n\tlogger := mi.vu.State().Logger.WithField(\"streamMethod\", methodName)\n\n\ts := &stream{\n\t\tvu:               mi.vu,\n\t\tclient:           client,\n\t\tmethodDescriptor: methodDescriptor,\n\t\tmethod:           methodName,\n\t\tlogger:           logger,\n","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/grpc/grpc.go#L105-L141","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","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"],"exampleFix":"// before\nclient.connect('localhost:8080');\nconst stream = new grpc.Stream(client, '/testing.TestService/ServerStream');\n\n// after\nclient.load(['protobufs'], 'service.proto'); // defines package testing\nclient.connect('localhost:8080');\nconst stream = new grpc.Stream(client, '/testing.TestService/ServerStream');","handlingStrategy":"try-catch","validationCode":"// No public JS API lists loaded methods; at minimum assert the proto loaded\nconst loaded = client.load(['protobufs'], 'service.proto');\nif (!loaded || loaded.length === 0) {\n  throw new Error('service.proto failed to load; refusing to build a stream');\n}","typeGuard":null,"tryCatchPattern":"let stream;\ntry {\n  stream = new grpc.Stream(client, METHOD);\n} catch (err) {\n  if (String(err.message).includes(\"invalid GRPC Stream's method\")) {\n    console.error(`method ${METHOD} unknown: check client.load() paths or enable server reflection with reflect: true`);\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["grpc","stream","method","proto","reflection"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}