egametang/ET · critical · Exception

location proxy message sender is null: {self.Root().Name}

Error message

location proxy message sender is null: {self.Root().Name}

What it means

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.

Source

Thrown at Packages/cn.etetet.actorlocation/Scripts/Hotfix/Server/LocationProxyComponentSystem.cs:132

                }

                string primarySceneName = string.Empty;
                ulong primaryPriorityId = 0;
                try
                {
                    primarySceneName = self.GetPrimaryLocationSceneName();
                    primaryPriorityId = self.primaryLocationPriorityId;
                    ServiceDiscoveryProxy serviceDiscoveryProxy = self.Root().GetComponent<ServiceDiscoveryProxy>();
                    ActorId primaryActorId = serviceDiscoveryProxy.GetServiceInfo(primarySceneName).ActorId;
                    if (primaryActorId == default)
                    {
                        throw new Exception($"location primary actor id is empty: {primarySceneName}");
                    }

                    MessageSender messageSender = self.Root().GetComponent<MessageSender>();
                    if (messageSender == null)
                    {
                        throw new Exception($"location proxy message sender is null: {self.Root().Name}");
                    }

                    IResponse response = await messageSender.Call(primaryActorId, request);
                    if (response.Error == ErrorCode.ERR_LocationFollowerRejected
                        || response.Error == ErrorCode.ERR_LocationPrimaryUnavailable)
                    {
                        ++retryCount;
                        self = selfRef;
                        if (self == null)
                        {
                            return response;
                        }

                        self.ClearPrimary($"response-error:{response.Error}");
                        Log.Warning(
                            $"location proxy retry after primary rejection key: {key} scene: {primarySceneName} priorityId: {primaryPriorityId} retry: {retryCount}/{self.locationRequestRetryTimes} error: {response.Error} message: {response.Message}");

                        if (retryCount >= self.locationRequestRetryTimes)

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Ensure the scene that hosts LocationProxyComponent also adds MessageSender during FiberInit.
  2. Check FiberInit for the scene type -- it should include root.AddComponent<MessageSender>().
  3. Verify MessageSender is not conditionally skipped due to configuration errors.

Example fix

// before -- scene missing MessageSender
root.AddComponent<LocationProxyComponent>();

// after -- add MessageSender before using location proxy
root.AddComponent<MessageSender>();
root.AddComponent<LocationProxyComponent>();
Defensive patterns

Strategy: validation

Validate before calling

MessageSender sender = root.GetComponent<MessageSender>();
if (sender == null)
{
    throw new InvalidOperationException(
        $"MessageSender missing on scene {root.Name} -- cannot use LocationProxyComponent");
}

Type guard

static bool HasMessageSender(Scene root) => root.GetComponent<MessageSender>() != null;

Try / catch

try
{
    await locationProxy.Add(type, key, actorId);
}
catch (Exception e) when (e.Message.Contains("message sender is null"))
{
    Log.Error($"Scene not initialized with MessageSender: {e.Message}");
    throw;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/ef9c79179d6b79fc. Report an issue: GitHub.