slawlor / ractor

Rust actor framework
MIT License
1.52k stars 73 forks source link

We should only notify the stop listener AFTER `post_stop` #257

Closed slawlor closed 2 months ago

slawlor commented 2 months ago

We should only notify the stop listener AFTER post_stop has executed, which is when the state gets set to Stopped

Closes #254

Test plan

A new test has been added called actor_post_stop_executed_before_stop_and_wait_returns. Before the fix it fails with

---- actor::tests::actor_post_stop_executed_before_stop_and_wait_returns stdout ----
2024-09-13T15:47:34.344047Z TRACE actor_post_stop_executed_before_stop_and_wait_returns:Actor{id="0.0"}: ractor::actor: Actor Local(0) stopped with no reason
thread 'actor::tests::actor_post_stop_executed_before_stop_and_wait_returns' panicked at ractor/src/actor/tests/mod.rs:1040:5:
assertion `left == right` failed
  left: 1
 right: 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    actor::tests::actor_post_stop_executed_before_stop_and_wait_returns

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 82 filtered out; finished in 0.02s

and with the patch here it succeeds.