Why does my actix Supervisor not retry stopped actors?

722 Views Asked by At

I have implemented an actix actor including the Supervised trait. I then tried to start the actor in a supervised way using

let _: Addr<Unsync, _> = Supervisor::start(|_| MyActor::default());

Unfortunately when that actor stops it is not automatically restarted for some reason.


Dependency Versions

actix = "0.5"
1

There are 1 best solutions below

2
On BEST ANSWER

Nikolay Kim, the author of actix, helped me analyze the issue. It turns out that assigning the Supervisor::start() result to a variable called _ will automatically throw away the result and so the supervisor will not actually start correctly.

The solution to this issue is renaming the _ variable to _addr:

let _addr: Addr<Unsync, _> = Supervisor::start(|_| MyActor::default());

After the rename the Supervisor correctly restarts the MyActor actor after it has stopped.