Skip to content

fix(receiver): harden callback draining during shutdown#644

Open
GefMar wants to merge 1 commit into
masterfrom
fix/receiver-callback-drain
Open

fix(receiver): harden callback draining during shutdown#644
GefMar wants to merge 1 commit into
masterfrom
fix/receiver-callback-drain

Conversation

@GefMar

@GefMar GefMar commented Jul 13, 2026

Copy link
Copy Markdown
Member
  • keep callback tasks owned until cleanup completes
  • prevent AnyIO level-cancellation busy loops
  • preserve interruptible unbounded graceful waits
  • release execution capacity exactly once
  • clarify wait-tasks-timeout semantics
  • add deterministic lifecycle and cancellation tests

Problem

Receiver callbacks could become orphaned or remain incompletely drained during worker shutdown.

The issue occurs when a message callback is still running while the receiver is being cancelled, especially when:

  • --wait-tasks-timeout expires;
  • the worker receives SIGINT or SIGTERM;
  • cancellation is delivered repeatedly;
  • an AnyIO cancel scope continues applying level cancellation during cleanup.

In these cases, cancellation could interrupt the callback-draining path itself. This could leave callback work without a clear owner, skip cleanup, or release prefetch capacity incorrectly. Repeated AnyIO cancellation could also cause a busy loop while the receiver attempted to finish cancellation cleanup.

- keep callback tasks owned until cleanup completes
- prevent AnyIO level-cancellation busy loops
- preserve interruptible unbounded graceful waits
- release execution capacity exactly once
- clarify wait-tasks-timeout semantics
- add deterministic lifecycle and cancellation tests
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.86%. Comparing base (ae2b788) to head (88fa10f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #644      +/-   ##
==========================================
+ Coverage   81.29%   81.86%   +0.56%     
==========================================
  Files          69       69              
  Lines        2577     2619      +42     
==========================================
+ Hits         2095     2144      +49     
+ Misses        482      475       -7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GefMar GefMar requested a review from s3rius July 14, 2026 07:18
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.

1 participant