Skip to content

Commit 6f08459

Browse files
fix: use TestProbe instead of TestActor in ClusterShardingDistributedDataSpecs to avoid stale dead ref on Windows (#747)
On Windows CI, TestActor can survive EnsureTestActorAliveAsync's liveness check but then die in the narrow window before the test body runs, leaving TestActor as a dead ActorRef. All Identify replies then land in dead letters and ExpectMsgAsync times out every retry. A TestProbe created in the test body is unaffected by the startup race since it is created post-startup.
1 parent ab5c80d commit 6f08459

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Akka.Cluster.Hosting.Tests/ClusterShardingDistributedDataSpecs.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ await AwaitAssertAsync(() =>
4848
var coordinatorName = settings.RestartReplicatorOnFailure ? $"{ReplicatorName}Supervisor" : ReplicatorName;
4949

5050
var actorSelection = Sys.ActorSelection(new RootActorPath(cluster.SelfAddress) / "user" / coordinatorName);
51-
51+
52+
// Use a fresh TestProbe rather than TestActor: on Windows, TestActor can be a stale dead
53+
// reference due to the startup race window between EnsureTestActorAliveAsync and the test body.
54+
var probe = CreateTestProbe();
5255
await AwaitAssertAsync(async () =>
5356
{
54-
actorSelection.Tell(new Identify("coordinator"), TestActor);
55-
var identity = await ExpectMsgAsync<ActorIdentity>(TimeSpan.FromSeconds(1));
57+
actorSelection.Tell(new Identify("coordinator"), probe.Ref);
58+
var identity = await probe.ExpectMsgAsync<ActorIdentity>(TimeSpan.FromSeconds(1));
5659
Assert.NotNull(identity.Subject);
5760
}, duration: TimeSpan.FromSeconds(10));
5861
}

0 commit comments

Comments
 (0)