Skip to content

fix(#446605): broaden shutdown OperationCanceledException guard in ReceiverWrapper#114

Merged
benspeth merged 1 commit into
masterfrom
teams/core/209/task/446605
Jun 9, 2026
Merged

fix(#446605): broaden shutdown OperationCanceledException guard in ReceiverWrapper#114
benspeth merged 1 commit into
masterfrom
teams/core/209/task/446605

Conversation

@ecofrankie

Copy link
Copy Markdown
Collaborator

Summary

  • Removes oce.CancellationToken.IsCancellationRequested from the guard in ReceiverWrapper.OnExceptionOccured
  • The Azure ServiceBus SDK raises ProcessErrorAsync with a TaskCanceledException whose .CancellationToken is CancellationToken.None during shutdown — the previous guard never fired
  • Widening to any OperationCanceledException is safe: genuine transport errors surface as ServiceBusException, not OperationCanceledException
  • Adds tests covering CancellationToken.None (the actual SDK case) and a dedicated TaskCanceledException variant

Context

PR #204351 shipped as v5.7.2 with a guard checking IsCancellationRequested. Post-deployment APM analysis (ADO task #446605 / US #442484) confirmed 30 TaskCanceledException errors still appearing in a shutdown burst — the Azure SDK sets the token to CancellationToken.None internally so the guard was always false.

Test plan

  • OnExceptionOccured_WithOperationCanceledException_DoesNotLogError — SDK shutdown path with CancellationToken.None
  • OnExceptionOccured_WithTaskCanceledException_DoesNotLogError — explicit TaskCanceledException case
  • OnExceptionOccured_WithNonCancelledToken_LogsError — confirms genuine errors still log at Error

@benspeth benspeth self-requested a review June 9, 2026 08:01
…o cover CancellationToken.None

The previous guard checked oce.CancellationToken.IsCancellationRequested, but the Azure
ServiceBus SDK raises ProcessErrorAsync with a TaskCanceledException whose CancellationToken
is CancellationToken.None during processor shutdown — so IsCancellationRequested is always
false and the guard never fired. Widening to any OperationCanceledException is safe because
genuine transport errors are ServiceBusException, not OperationCanceledException.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ecofrankie ecofrankie force-pushed the teams/core/209/task/446605 branch from 0ddd607 to 596055e Compare June 9, 2026 08:13
@benspeth benspeth merged commit b8e67e3 into master Jun 9, 2026
1 check 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.

2 participants