-
Notifications
You must be signed in to change notification settings - Fork 84
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
fix: Ensure pending messages are delivered when OutputPort is dropped. #293
Conversation
#[crate::concurrency::test] | ||
#[tracing_test::traced_test] | ||
async fn test_delivery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test consistently fails with the version on the main branch, and passes when Drop
is removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for the contribution
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #293 +/- ##
==========================================
+ Coverage 81.30% 81.33% +0.03%
==========================================
Files 60 60
Lines 10856 10890 +34
==========================================
+ Hits 8826 8857 +31
- Misses 2030 2033 +3 ☔ View full report in Codecov by Sentry. |
Please run rustfmt then update the pr, then it's good to merge! |
@slawlor sorry I missed that – done! |
I'll try and get a version cut today with this fix included |
appreciate it @slawlor! |
V0.13.2 has this included. |
Summary
This PR ensures that pending messages are delivered when an
OutputPort
is dropped.Overview
This PR removes the
Drop
implementation fromOutputPort<T>
, which called thestop
function on all subscribers:ractor/ractor/src/port/output/mod.rs
Lines 107 to 113 in 1949d92
Calling the
stop
function would abort theJoinHandle
of the subscriber:ractor/ractor/src/port/output/mod.rs
Lines 132 to 134 in 1949d92
which would immediately terminate the tokio task responsible for delivering messages to the subscriber:
ractor/ractor/src/port/output/mod.rs
Lines 147 to 156 in 1949d92
Removing the
Drop
implementation still results in the tasks properly shutting down, as per thetokio
documentation for closing broadcast channels:The implementation of the receive pump will exit when the channel does not return an
Ok
result:ractor/ractor/src/port/output/mod.rs
Line 148 in 1949d92