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

Sender() set to deadLetters when message forwarded asynchronously #159

Open
sbacquet opened this issue Sep 13, 2022 · 3 comments
Open

Sender() set to deadLetters when message forwarded asynchronously #159

sbacquet opened this issue Sep 13, 2022 · 3 comments

Comments

@sbacquet
Copy link

When a message is forwarded (<<!) within an async block, forwardee.Sender() returns the deadLetters actor, hence the real sender cannot received any message back from the forwardee.
It works fine when the message is forwarded synchronously.

Attached is a project to demonstrate the bug.

DeadLetterBug.zip

@sbacquet
Copy link
Author

It seems to be a thread issue.
Indeed, it works OK when forwarding inside a task {} block instead of an async {} block.
I will need to replace all my async {} with task {} :(

As the Task API seems more robust/battle tested than the Async one, is it planned to replace all Async functions with Task functions in Akkling ? (the <? operator in particular)

@Horusiath
Copy link
Owner

I don't mind doing it, it would however break compatibility with existing API. Perhaps we could put Async/Task related APIs into their respective modules and let people choose for their own.

@sbacquet
Copy link
Author

Indeed, it's a shame that an Async can't bind to a Task, while the opposite is possible.
It may be added in a future version of F#, but in the meantime maybe Akkling could extend AsyncBuilder and add a Bind(Task<>) method ?

    [<AutoOpen>]
    module AsyncExtensions =
        type AsyncBuilder with
          member __.ReturnFrom(task: Task<'T>) : Async<'T> =
            Async.AwaitTask task
          member this.Bind(task: Task<'T>, binder: 'T -> Async<'U>) : Async<'U> =
            this.Bind(Async.AwaitTask task, binder)

This way, Akkling could define only Task<> returning functions, avoiding all the existing roundtrips Async->Task->Async with Async.AwaitTask and Async.StartAsTask everywhere in the code for Akka.NET interop.
The user could then equally call those functions inside a task {} or an async {} block.

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

2 participants