{"record":{"id":"ef9c79179d6b79fc","repo":"egametang/ET","slug":"location-proxy-message-sender-is-null-self-root","errorCode":null,"errorMessage":"location proxy message sender is null: {self.Root().Name}","messagePattern":"location proxy message sender is null: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"Packages/cn.etetet.actorlocation/Scripts/Hotfix/Server/LocationProxyComponentSystem.cs","lineNumber":132,"sourceCode":"                }\n\n                string primarySceneName = string.Empty;\n                ulong primaryPriorityId = 0;\n                try\n                {\n                    primarySceneName = self.GetPrimaryLocationSceneName();\n                    primaryPriorityId = self.primaryLocationPriorityId;\n                    ServiceDiscoveryProxy serviceDiscoveryProxy = self.Root().GetComponent<ServiceDiscoveryProxy>();\n                    ActorId primaryActorId = serviceDiscoveryProxy.GetServiceInfo(primarySceneName).ActorId;\n                    if (primaryActorId == default)\n                    {\n                        throw new Exception($\"location primary actor id is empty: {primarySceneName}\");\n                    }\n\n                    MessageSender messageSender = self.Root().GetComponent<MessageSender>();\n                    if (messageSender == null)\n                    {\n                        throw new Exception($\"location proxy message sender is null: {self.Root().Name}\");\n                    }\n\n                    IResponse response = await messageSender.Call(primaryActorId, request);\n                    if (response.Error == ErrorCode.ERR_LocationFollowerRejected\n                        || response.Error == ErrorCode.ERR_LocationPrimaryUnavailable)\n                    {\n                        ++retryCount;\n                        self = selfRef;\n                        if (self == null)\n                        {\n                            return response;\n                        }\n\n                        self.ClearPrimary($\"response-error:{response.Error}\");\n                        Log.Warning(\n                            $\"location proxy retry after primary rejection key: {key} scene: {primarySceneName} priorityId: {primaryPriorityId} retry: {retryCount}/{self.locationRequestRetryTimes} error: {response.Error} message: {response.Message}\");\n\n                        if (retryCount >= self.locationRequestRetryTimes)","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.actorlocation/Scripts/Hotfix/Server/LocationProxyComponentSystem.cs#L114-L150","documentation":"Thrown by CallPrimaryWithRetry when the scene root does not have a MessageSender component. MessageSender is required to send RPC messages to the primary Location scene. Every scene that uses LocationProxyComponent must also have MessageSender added during its fiber initialization. This is a scene setup/initialization failure.","triggerScenarios":"CallPrimaryWithRetry reaches the point where it needs to call messageSender.Call(primaryActorId, request), but self.Root().GetComponent<MessageSender>() returns null. The Location scene itself adds MessageSender in FiberInit_Location.cs:13, but the PROXY scene (the caller) must also have it.","commonSituations":"A scene that uses LocationProxyComponent was initialized without adding MessageSender; a custom FiberInit handler that adds LocationProxyComponent but forgets MessageSender; MessageSender was disposed due to a network error.","solutions":["Ensure the scene that hosts LocationProxyComponent also adds MessageSender during FiberInit.","Check FiberInit for the scene type -- it should include root.AddComponent<MessageSender>().","Verify MessageSender is not conditionally skipped due to configuration errors."],"exampleFix":"// before -- scene missing MessageSender\nroot.AddComponent<LocationProxyComponent>();\n\n// after -- add MessageSender before using location proxy\nroot.AddComponent<MessageSender>();\nroot.AddComponent<LocationProxyComponent>();","handlingStrategy":"validation","validationCode":"MessageSender sender = root.GetComponent<MessageSender>();\nif (sender == null)\n{\n    throw new InvalidOperationException(\n        $\"MessageSender missing on scene {root.Name} -- cannot use LocationProxyComponent\");\n}","typeGuard":"static bool HasMessageSender(Scene root) => root.GetComponent<MessageSender>() != null;","tryCatchPattern":"try\n{\n    await locationProxy.Add(type, key, actorId);\n}\ncatch (Exception e) when (e.Message.Contains(\"message sender is null\"))\n{\n    Log.Error($\"Scene not initialized with MessageSender: {e.Message}\");\n    throw;\n}","preventionTips":["Ensure every scene that uses LocationProxyComponent also adds MessageSender in its FiberInit.","Follow FiberInit_Location.cs:13 as the reference -- MessageSender is added before any location operations.","Validate required infrastructure components at scene startup."],"tags":["location","initialization","messaging","infrastructure","configuration"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}