Repository navigation
fix: abort scheduler tasks after shutdown timeout - #8832
Merged
Merged
Conversation
The timeout currently owns each IMAP and SMTP JoinHandle. When 30 seconds elapse, dropping the timeout drops the handle and detaches the task instead of cancelling it. On Haiku, a network task stuck behind a missed or delayed socket wakeup can therefore outlive scheduler shutdown, retaining connections and interfering with restart or active-account deletion. Borrow each handle while waiting, then explicitly abort and await it if shutdown times out. This guarantees that scheduler shutdown does not complete while a timed-out network task is still running.
Contributor
Author
link2xt
approved these changes
Oct 16, 2026
link2xt
left a comment
Collaborator
There was a problem hiding this comment.
Looks good. Unfortunate that tokio does not have proper structured concurrency. The closest approximate is JoinSet, but then we need to put all handles in a single place. There is also tokio_util::task::AbortOnDropHandle but it only calls .abort() without waiting for the task to actually finish and free resources afterwards.
Co-authored-by: l <link2xt@testrun.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The timeout currently owns each IMAP and SMTP JoinHandle. When 30 seconds elapse, dropping the timeout drops the handle and detaches the task instead of cancelling it. On Haiku, a network task stuck behind a missed or delayed socket wakeup can therefore outlive scheduler shutdown, retaining connections and interfering with restart or active-account deletion.
Borrow each handle while waiting, then explicitly abort and await it if shutdown times out. This guarantees that scheduler shutdown does not complete while a timed-out network task is still running.