{"record":{"id":"57baceb17bc4a7f5","repo":"temporalio/temporal","slug":"nexus-service-s-is-already-registered","errorCode":null,"errorMessage":"nexus service %s is already registered","messagePattern":"nexus service (.+?) is already registered","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chasm/registry.go","lineNumber":370,"sourceCode":"\treturn nil\n}\n\nfunc (r *Registry) warnUnmanagedFields(fqn string, rc *RegistrableComponent) {\n\tvar unmanagedFields []string\n\tfor f := range unmanagedFieldsOf(rc.goType) {\n\t\tunmanagedFields = append(unmanagedFields, fmt.Sprintf(\"%s %s\", f.name, f.typ))\n\t}\n\tif len(unmanagedFields) > 0 {\n\t\tr.logger.Info(fmt.Sprintf(\n\t\t\t\"Warning: CHASM component %s declares state fields that won't be managed by CHASM:\\n\\t%s\",\n\t\t\tfqn,\n\t\t\tstrings.Join(unmanagedFields, \"\\n\\t\")))\n\t}\n}\n\nfunc (r *Registry) registerNexusService(svc *nexus.Service) error {\n\tif _, ok := r.nexusServices[svc.Name]; ok {\n\t\treturn fmt.Errorf(\"nexus service %s is already registered\", svc.Name)\n\t}\n\tr.nexusServices[svc.Name] = svc\n\treturn nil\n}\n\n// NexusServices returns all registered Nexus services.\nfunc (r *Registry) NexusServices() map[string]*nexus.Service {\n\t// Return a copy to prevent external modification\n\tservices := make(map[string]*nexus.Service, len(r.nexusServices))\n\tmaps.Copy(services, r.nexusServices)\n\treturn services\n}\n\nfunc (r *Registry) componentContextValue(key any) any {\n\tif v, ok := r.rcContextValues[key]; ok {\n\t\treturn v.v\n\t}\n\treturn nil","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/chasm/registry.go#L352-L388","documentation":"registerNexusService rejects registering a nexus.Service whose Name already exists in r.nexusServices. Nexus service names must be unique in the registry because they route inbound Nexus calls to handlers.","triggerScenarios":"Registering the same nexus service name twice via chasm.Register; two packages' init() both registering a service with the same name; registering two distinct nexus.Service instances that share a name.","commonSituations":"Shared infrastructure package and app bootstrap both registering the same service name; renaming a service but leaving the old registration in place; multi-tenant setups reusing a name across libraries loaded into one binary.","solutions":["Remove the duplicate registration so each nexus service name is registered once.","Give the second service a unique name.","If both packages need the same service, export one registration and import it instead of duplicating."],"exampleFix":"// before\nreg.RegisterNexusService(nexus.NewService(\"billing\", ...))\nreg.RegisterNexusService(nexus.NewService(\"billing\", ...))\n// after\nreg.RegisterNexusService(nexus.NewService(\"billing\", ...))","handlingStrategy":"validation","validationCode":"if registeredNexusNames[svc.Name] {\n\treturn fmt.Errorf(\"nexus service %s already registered\", svc.Name)\n}","typeGuard":null,"tryCatchPattern":"if err := registerNexusService(reg, svc); err != nil && strings.Contains(err.Error(), \"is already registered\") {\n\treturn nil // idempotent bootstrap\n}","preventionTips":["Register each nexus service once from a single bootstrap path.","Keep a canonical list of service names and assert uniqueness at startup.","Avoid registering nexus services inside library init() functions."],"tags":["chasm","registry","nexus","duplicate-registration"],"backgroundTag":"duplicate-service-registration","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}