{"record":{"id":"b1ca338afd1cf4f0","repo":"grafana/k6","slug":"failed-to-register-grpc-module-metrics-w","errorCode":null,"errorMessage":"failed to register GRPC module metrics: %w","messagePattern":"failed to register GRPC module metrics: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/grpc/grpc.go","lineNumber":47,"sourceCode":"\t}\n)\n\nvar (\n\t_ modules.Module   = &RootModule{}\n\t_ modules.Instance = &ModuleInstance{}\n)\n\n// New returns a pointer to a new RootModule instance.\nfunc New() *RootModule {\n\treturn &RootModule{}\n}\n\n// NewModuleInstance implements the modules.Module interface to return\n// a new instance for each VU.\nfunc (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance {\n\tmetrics, err := registerMetrics(vu.InitEnv().Registry)\n\tif err != nil {\n\t\tcommon.Throw(vu.Runtime(), fmt.Errorf(\"failed to register GRPC module metrics: %w\", err))\n\t}\n\n\tmi := &ModuleInstance{\n\t\tvu:      vu,\n\t\texports: make(map[string]any),\n\t\tmetrics: metrics,\n\t}\n\n\tmi.exports[\"Client\"] = mi.NewClient\n\tmi.defineConstants()\n\tmi.exports[\"Stream\"] = mi.stream\n\n\treturn mi\n}\n\n// NewClient is the JS constructor for the grpc Client.\nfunc (mi *ModuleInstance) NewClient(_ sobek.ConstructorCall) *sobek.Object {\n\trt := mi.vu.Runtime()","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/grpc/grpc.go#L29-L65","documentation":"Raised in the grpc RootModule's NewModuleInstance when registerMetrics fails against the metric registry — a metric name collision or registry error at module instantiation. This is thrown as a script runtime exception via common.Throw, not returned.","triggerScenarios":"Thrown at internal/js/modules/k6/grpc/grpc.go:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check for custom or extension metrics conflicting with the built-in grpc metric names (grpc_req_duration etc.)","Report as a k6 bug if no conflicting metric registration exists"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}