Skip to content

Tolerate dispose failures when stopping ASB receive endpoints - #10315

Merged
glen-84 merged 2 commits into
mainfrom
gai/asb-stop-dispose-best-effort
Aug 31, 2026
Merged

glen-84 merged 2 commits into
mainfrom
gai/asb-stop-dispose-best-effort

Conversation

@glen-84

@glen-84 glen-84 commented Aug 30, 2026

Copy link
Copy Markdown
Member

Summary

  • AzureServiceBusReceiveEndpoint.OnStopAsync now treats heartbeat and processor disposal as best-effort: a failure while releasing either resource is logged as a warning instead of failing the stop, and a heartbeat dispose failure no longer skips processor disposal.
  • This fixes a flaky CI teardown failure (example run) where ServiceBusProcessor.DisposeAsync hit the 60-second AMQP link-drain timeout against the Service Bus emulator and failed a test whose assertions had already passed.

Test plan

  • New unit tests in ReceiveEndpointLifecycleUnitTests: a processor dispose failure completes the stop and logs a warning, and a heartbeat dispose failure still disposes the processor. Both were confirmed failing before the fix.
  • Full Mocha.Transport.AzureServiceBus.Tests suite against the emulator: 337 passed, 0 failed, 2 known emulator-bug skips.

Copilot AI lite review requested due to automatic review settings August 30, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes AzureServiceBusReceiveEndpoint.OnStopAsync resilient to teardown failures by treating heartbeat and processor disposal as best-effort cleanup, logging disposal failures as warnings instead of failing the stop. It also adds unit tests to prevent regressions in stop/teardown behavior, targeting a flaky CI teardown scenario.

Changes:

  • Wrap heartbeat and processor disposal in try/catch during endpoint stop and log failures at Warning without aborting stop.
  • Add unit tests validating stop completes and warnings are logged when disposal fails, and that heartbeat failures don’t skip processor disposal.
  • Extend the test FakeServiceBusProcessor with a controllable close-failure injection to simulate SDK teardown timeouts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Mocha/src/Mocha.Transport.AzureServiceBus/AzureServiceBusReceiveEndpoint.cs Makes stop teardown best-effort for heartbeat/processor disposal and adds structured warning logs.
src/Mocha/test/Mocha.Transport.AzureServiceBus.Tests/ReceiveEndpointLifecycleUnitTests.cs Adds lifecycle tests for disposal-failure tolerance and correct disposal ordering/behavior.
src/Mocha/test/Mocha.Transport.AzureServiceBus.Tests/Helpers/FakeServiceBusClient.cs Adds failure injection to the fake processor to simulate teardown failures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (14/14)

File Covered Changed Patch %
…/AzureServiceBusReceiveEndpoint.cs 14 14 100.0% 🟢

Project coverage: 57.7% (285999/495778 lines)

@glen-84
glen-84 requested a review from PascalSenn August 30, 2026 14:01
@glen-84
glen-84 merged commit c67979f into main Aug 31, 2026
151 checks passed
@glen-84
glen-84 deleted the gai/asb-stop-dispose-best-effort branch August 31, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants