Operation canceled: Microsoft Graph .NET SDK CancellationToken propagation
0 reputation · 02 Sept 2023, 08:19 UTC
Cancellation behavior in Microsoft Graph SDK
When utilizing the Microsoft Graph .NET SDK (v5.0+), developers can pass a CancellationToken to asynchronous methods to manage request lifecycles. While the SDK is designed to throw an OperationCanceledException when a token is triggered, there is uncertainty regarding how this cancellation propagates through the underlying HttpClient and downstream Microsoft 365 services.
Backend propagation and timeouts
The default HttpClient configuration typically implements a 100-second timeout. However, when a request is handed off to backend services—such as Exchange Online or Azure AD—it is unclear if the cancellation of the client-side token effectively terminates the processing on the server side or if the backend continues to execute the operation until a timeout occurs.
This creates a gap in understanding whether client-side cancellation truly reduces backend load or simply ignores the eventual response.
- Does the
CancellationTokenreliably trigger an immediate abort of the HTTP request in the underlyingHttpClient? - Is there documented behavior confirming that cancellation tokens propagate to downstream M365 service providers to stop backend processing?