diff --git a/src/Proto.Cluster/DefaultClusterContext.cs b/src/Proto.Cluster/DefaultClusterContext.cs index 6e1967af5f..33b7c15a62 100644 --- a/src/Proto.Cluster/DefaultClusterContext.cs +++ b/src/Proto.Cluster/DefaultClusterContext.cs @@ -52,11 +52,16 @@ public DefaultClusterContext(Cluster cluster) public async Task RequestAsync(ClusterIdentity clusterIdentity, object message, ISenderContext context, CancellationToken ct) { - if (!_cluster.JoinedCluster.IsCompletedSuccessfully) + + //for member requests, we need to wait for the cluster to be ready + if (!_cluster.MemberList.IsClient) { - await _cluster.JoinedCluster; + if (!_cluster.JoinedCluster.IsCompletedSuccessfully) + { + await _cluster.JoinedCluster; + } } - + var i = 0; var future = context.GetFuture(); diff --git a/src/Proto.Cluster/Member/MemberList.cs b/src/Proto.Cluster/Member/MemberList.cs index 4e328fd836..1c9140878d 100644 --- a/src/Proto.Cluster/Member/MemberList.cs +++ b/src/Proto.Cluster/Member/MemberList.cs @@ -60,14 +60,16 @@ public record MemberList private TaskCompletionSource _startedTcs = new(TaskCreationOptions.RunContinuationsAsynchronously); private IConsensusHandle? _topologyConsensus; - private readonly bool _asClient; + private readonly bool _isClient; - public MemberList(Cluster cluster, bool asClient = false) + public bool IsClient => _isClient; + + public MemberList(Cluster cluster, bool isClient = false) { _cluster = cluster; _system = _cluster.System; _root = _system.Root; - _asClient = asClient; + _isClient = isClient; var (host, port) = _cluster.System.GetAddress(); Self = new Member @@ -239,7 +241,7 @@ public void UpdateClusterTopology(IReadOnlyCollection members) if (!_startedTcs.Task.IsCompleted) { - if (_asClient || activeMembers.Contains(_system.Id)) + if (_isClient || activeMembers.Contains(_system.Id)) { _startedTcs.TrySetResult(true); }