[Bug] SemaphoreFullException in ClientCredentialRequest when cancellation token is canceled #4472
Labels
bug
confidential-client
P2
regression
Behavior that worked in a previous release that no longer works in a newer release
scenario:ManagedIdentity
Milestone
Library version used
4.56.0
.NET version
Scenario
ManagedIdentityClient - managed identity
Is this a new or an existing app?
None
Issue description and reproduction steps
microsoft-authentication-library-for-dotnet/src/client/Microsoft.Identity.Client/Internal/Requests/ClientCredentialRequest.cs
Line 121 in 546d00f
The semaphore.Wait is called inside a try. When the cancellation token is cancelled, a TaskCancelledException is thrown without the semaphore being acquired, and finally is called trying to release the semaphore which was not acquired causing a SemaphoreFullException.
Relevant code snippets
No response
Expected behavior
When cancellation token is cancelled, the request should be cancelled. The semaphore.Wait should be called outside of the try statement.
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
Regression in 4.56.0 - #4309
Solution and workarounds
No response
The text was updated successfully, but these errors were encountered: