Skip to content

Commit 3eae9c1

Browse files
authored
fix client issue (#2091)
1 parent a3e0ba9 commit 3eae9c1

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/Proto.Cluster/DefaultClusterContext.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,16 @@ public DefaultClusterContext(Cluster cluster)
5252
public async Task<T?> RequestAsync<T>(ClusterIdentity clusterIdentity, object message, ISenderContext context,
5353
CancellationToken ct)
5454
{
55-
if (!_cluster.JoinedCluster.IsCompletedSuccessfully)
55+
56+
//for member requests, we need to wait for the cluster to be ready
57+
if (!_cluster.MemberList.IsClient)
5658
{
57-
await _cluster.JoinedCluster;
59+
if (!_cluster.JoinedCluster.IsCompletedSuccessfully)
60+
{
61+
await _cluster.JoinedCluster;
62+
}
5863
}
59-
64+
6065
var i = 0;
6166

6267
var future = context.GetFuture();

src/Proto.Cluster/Member/MemberList.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ public record MemberList
6060

6161
private TaskCompletionSource<bool> _startedTcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
6262
private IConsensusHandle<ulong>? _topologyConsensus;
63-
private readonly bool _asClient;
63+
private readonly bool _isClient;
6464

65-
public MemberList(Cluster cluster, bool asClient = false)
65+
public bool IsClient => _isClient;
66+
67+
public MemberList(Cluster cluster, bool isClient = false)
6668
{
6769
_cluster = cluster;
6870
_system = _cluster.System;
6971
_root = _system.Root;
70-
_asClient = asClient;
72+
_isClient = isClient;
7173
var (host, port) = _cluster.System.GetAddress();
7274

7375
Self = new Member
@@ -239,7 +241,7 @@ public void UpdateClusterTopology(IReadOnlyCollection<Member> members)
239241

240242
if (!_startedTcs.Task.IsCompleted)
241243
{
242-
if (_asClient || activeMembers.Contains(_system.Id))
244+
if (_isClient || activeMembers.Contains(_system.Id))
243245
{
244246
_startedTcs.TrySetResult(true);
245247
}

0 commit comments

Comments
 (0)