Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FishForMessageAsync deadlocks with actor that has async receive handler and testprobe.Tell #7120

Closed
SchiessMax opened this issue Mar 13, 2024 · 1 comment

Comments

@SchiessMax
Copy link

Version Information
Akka.TestKit.Xunit2 1.5.15 and upwards (works with 1.5.14)

Describe the bug
FishForMessage in combination with tell on an actor with async receive handler that calls "Tell" on the test probe that triggered the handler.

To Reproduce
Steps to reproduce the behavior:

  1. Execute Unittest with debugger:
using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.TestKit.Xunit2;
using Xunit;

namespace CODESYS.CAS.TaskManager.UnitTests;

public class Foobar : TestKit
{
    private class AsyncActor : ReceiveActor
    {
        private readonly IActorRef _probe;

        public AsyncActor(IActorRef probe)
        {
            _probe = probe;
            ReceiveAnyAsync(async msg =>
            {
                _probe.Tell(msg);
                await Task.CompletedTask;
            });
        }
    }
    
    [Fact]
    public async Task Deadlock()
    {
        var probe = CreateTestProbe();
        var testee = Sys.ActorOf(Props.Create(() => new AsyncActor(probe)));
        var msg = 123;
        
        testee.Tell("foobar");
        testee.Tell(msg);
        
        await probe.FishForMessageAsync(m => m.Equals(msg), TimeSpan.FromDays(1));
    }
}
  1. Unittest deadlocks
  2. Pause debugger: unittest is deadlocked on _probe.Tell(msg);

Expected behavior
Unittest should pass - no deadlock should occur.

Actual behavior
The unittest deadlocked.

Environment
Windows, .net 8

@SchiessMax
Copy link
Author

This was fixed with Version 1.5.19, I think with #7157
The unit test provided above now passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant