Skip to content

fix: abort scheduler tasks after shutdown timeout - #8832

Merged
link2xt merged 2 commits into
chatmail:mainfrom
trufae:haiku-scheduler-shutdown
Oct 16, 2026
Merged

link2xt merged 2 commits into
chatmail:mainfrom
trufae:haiku-scheduler-shutdown

Conversation

@trufae

@trufae trufae commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@trufae

trufae commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@link2xt link2xt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/scheduler.rs Outdated
Comment thread src/scheduler.rs Outdated
Co-authored-by: l <link2xt@testrun.org>
@link2xt
link2xt merged commit d62438d into chatmail:main Oct 16, 2026
21 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants