egametang/ET · critical · RpcException

ERR_LocationPrimaryUnavailable

ERR_LocationPrimaryUnavailable

Error message

not found location scene in zone: {self.Zone()}

What it means

Thrown by LocationProxyComponent.GetPrimaryLocationSceneName when service discovery returns zero Location-type scenes for the current zone. The proxy cannot route any location request (Add, Remove, Lock, UnLock, Get) without a primary Location scene. This is a topology/deployment issue -- no Location scene is running or discoverable in the zone.

Source

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

                await ETTask.CompletedTask;
            }
        }

        [EntitySystem]
        private static void Awake(this LocationProxyComponent self)
        {
            self.primaryLocationPriorityId = 0;
            self.locationRequestRetryTimes = 20;
            self.locationRequestRetryIntervalMs = 100;
        }

        private static string GetPrimaryLocationSceneName(this LocationProxyComponent self)
        {
            ServiceDiscoveryProxy serviceDiscoveryProxy = self.Root().GetComponent<ServiceDiscoveryProxy>();
            List<ServiceInfo> serviceInfos = serviceDiscoveryProxy.GetBySceneType(SceneType.Location);
            if (serviceInfos.Count == 0)
            {
                throw new RpcException(ErrorCode.ERR_LocationPrimaryUnavailable, $"not found location scene in zone: {self.Zone()}");
            }

            ServiceInfo stablePrimaryServiceInfo = LocationPrimaryHelper.SelectStablePrimaryServiceInfo(serviceInfos);
            string stablePrimarySceneName = stablePrimaryServiceInfo.SceneName;
            ulong stablePrimaryPriorityId = LocationPrimaryHelper.GetPriorityId(stablePrimaryServiceInfo);
            string primarySceneName = self.primaryLocationSceneName;
            ulong primaryPriorityId = self.primaryLocationPriorityId;
            if (primarySceneName == stablePrimarySceneName && primaryPriorityId == stablePrimaryPriorityId)
            {
                return stablePrimarySceneName;
            }

            self.primaryLocationSceneName = stablePrimarySceneName;
            self.primaryLocationPriorityId = stablePrimaryPriorityId;
            Log.Info(
                $"location proxy primary switch: {primarySceneName}({primaryPriorityId}) -> {stablePrimarySceneName}({stablePrimaryPriorityId}) scene: {self.Root().Name}");
            return stablePrimarySceneName;
        }

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Ensure at least one StartSceneConfig with SceneType.Location exists for the zone.
  2. Verify the Location scene process is running and has completed FiberInit_Location (check for 'location node registered' log).
  3. Check service discovery connectivity -- the proxy must be able to reach ServiceDiscoveryProxy.GetBySceneType.
  4. If this is transient (scene restarting), CallPrimaryWithRetry will retry up to locationRequestRetryTimes (default 20).

Example fix

// No code fix -- this is a deployment/topology issue.
// Ensure StartSceneConfig includes a Location scene for the zone:
// { SceneType = SceneType.Location, Zone = X, ... }
Defensive patterns

Strategy: retry

Try / catch

// CallPrimaryWithRetry already retries ERR_LocationPrimaryUnavailable up to 20 times.
// At the top-level caller, catch after retries are exhausted:
try
{
    await locationProxy.Add(type, key, actorId);
}
catch (RpcException e) when (e.Error == ErrorCode.ERR_LocationPrimaryUnavailable)
{
    Log.Error($"No Location scene available in zone after retries: {e.Message}");
    throw;
}

Prevention

When it happens

Trigger: CallPrimaryWithRetry calls GetPrimaryLocationSceneName, which queries serviceDiscoveryProxy.GetBySceneType(SceneType.Location) and the result count is 0. Every proxy operation (Add, Lock, Get, etc.) goes through CallPrimaryWithRetry, so all location operations fail with this error.

Common situations: No Location scene is configured in StartSceneConfig for the zone; the Location scene crashed and hasn't restarted; service discovery itself is down or not returning Location scenes; the SceneType.Location registration/subscription in FiberInit_Location failed; network partition between the proxy scene and service discovery.

Related errors


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