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

Supervisors cannot be stopped (formerly "Supervisor causes panic") #27

Open
hoodie opened this issue Sep 26, 2020 · 1 comment · Fixed by #28 · May be fixed by #48
Open

Supervisors cannot be stopped (formerly "Supervisor causes panic") #27

hoodie opened this issue Sep 26, 2020 · 1 comment · Fixed by #28 · May be fixed by #48

Comments

@hoodie
Copy link
Contributor

hoodie commented Sep 26, 2020

Hi there,
thanks for the nice crate 👍
I was trying out Supervisors though and I don't quite understand how to use them. I seem to always get a panic inside of futures-channels mpcs code when I launch one.

here is a minimal example

use xactor::Actor;

pub struct ServiceA {
    pub session_id: u32,
}

#[async_trait::async_trait]
impl Actor for ServiceA { }

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    xactor::Supervisor::start(|| ServiceA { session_id: 4 }).await?;

    Ok(())
}

this causes a panic with the following messages for me

thread 'async-std/runtime' panicked at 'Receiver::next_message called after `None`', /home/hoodie/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-channel-0.3.5/src/mpsc/mod.rs:1141:41

do you have any idea what could be the reason for this?

thank you

@hoodie
Copy link
Contributor Author

hoodie commented Sep 27, 2020

Hi there, seems I was holding it wrong.
Of course what I forgot to hold and await the Addr that is being returned from start like this:

    let service_supervisor = xactor::Supervisor::start(|| ServiceA { session_id: 4 }).await?;
    service_supervisor.wait_for_stop().await;

how every this reveals another issue, namely that supervisors cannot be stopped 😉 and if they are dropped (as in my original example) they simply cause the Receiver::next_message in futures-channel mpsc to panic.

@hoodie hoodie changed the title Supervisor causes panic Supervisors cannot be stopped (formerly "Supervisor causes panic") Sep 27, 2020
sunli829 added a commit that referenced this issue Sep 28, 2020
Don't call rx.next after receiving None, fixes #27
@sunli829 sunli829 reopened this Sep 28, 2020
@hoodie hoodie linked a pull request Oct 10, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants