Akka.Actor: FutureActorRef<T>
does not support Context.Watch
and may cause memory leaks
#7501
Labels
Milestone
Version Information
Version of Akka.NET? v1.5.37 and earlier
Which Akka.NET Modules? Akka
Describe the bug
Related to akkadotnet/Akka.Persistence.Sql#516 - basically, any actor that calls
Context.Watch
will never get aTerminated
message back for a death-watchedFutureActorRef<T>
even once it completes itsTaskCompletionSource<T>
, which can lead to memory leaks and other undefined system behavior.To Reproduce
Expected behavior
Either
Context.Watch
should no-op for the calling actor if the target is aFutureActorRef<T>
orContext.Watch
should work properly and the invoking actor should receive aTerminated
message back from theFutureActorRef<T>
.Actual behavior
Actor invokes
Context.Watch
and stores theFutureActorRef<T>
in its death watch collection and never releases it, which causes theTaskCompletionSource<T>
/Task<T>
/ the resultT
all to get rooted and retained in-memory.Additional context
As a general design rule, I don't think the caller should have to be aware or care what the implementation of an
IActorRef
is when callingContext.Watch
- it should "just work."The text was updated successfully, but these errors were encountered: