Repository navigation
Tolerate dispose failures when stopping ASB receive endpoints - #10315
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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/catchduring endpoint stop and log failures atWarningwithout 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
FakeServiceBusProcessorwith 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.
Contributor
Patch coverage100.0% of changed lines covered (14/14)
Project coverage: 57.7% (285999/495778 lines) |
PascalSenn
approved these changes
Aug 31, 2026
glen-84
added a commit
that referenced
this pull request
Sep 23, 2026
This was referenced Sep 26, 2026
Merged
This was referenced Oct 3, 2026
This was referenced Oct 5, 2026
Open
Open
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.
Summary
AzureServiceBusReceiveEndpoint.OnStopAsyncnow 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.ServiceBusProcessor.DisposeAsynchit the 60-second AMQP link-drain timeout against the Service Bus emulator and failed a test whose assertions had already passed.Test plan
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.Mocha.Transport.AzureServiceBus.Testssuite against the emulator: 337 passed, 0 failed, 2 known emulator-bug skips.