RFC: Modernizing CancellationToken Usage in Async APIs #285
Replies: 7 comments 3 replies
-
|
I want to keep it short. That's the right way to go. It probably will only be breaking for a small percentage of the userbase. Does this proposal mean that you drop the idea of dropping the async suffix? |
Beta Was this translation helpful? Give feedback.
-
|
I'll also welcome this change. It's the "standard" and the normal behaviour a library user expects. |
Beta Was this translation helpful? Give feedback.
-
|
This would be a much preferred change. While it is breaking for some, the "fix" in this case is pretty straight forward. I think it would be very worth the time to fix any issues to align better with standards in C#. |
Beta Was this translation helpful? Give feedback.
-
|
Yes, I think this would be a welcome change, as it is pretty much a standard convention I think most are familiar with. It would be pretty easy to fix any compile errors. |
Beta Was this translation helpful? Give feedback.
-
|
Could you give a list of what methods this would actually change, or at least some good examples, so I could check our code? |
Beta Was this translation helpful? Give feedback.
-
|
Related: https://github.com/orgs/DuendeSoftware/discussions/323 |
Beta Was this translation helpful? Give feedback.
-
|
As someone who is implementing custom stores, this would be a welcome change. I'd like to be able to take a dependency on just the store interfaces and not have to worry about ICancellationTokenProvider as I do now. Given that this will hopefully be done in a major version release, I don't see the fact that this is a breaking change as much of an issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone,
We're considering a significant change to how IdentityServer handles asynchronous operations, and we need your feedback before moving forward.
TL;DR: We want to add
CancellationTokenparameters to our async APIs. This is the standard, idiomatic C# approach, but it would be a major breaking change. We want to know if the benefits are worth the migration effort for you.The Current Situation
Currently, most async APIs in IdentityServer don't accept a
CancellationTokenparameter. Instead, you resolve anICancellationTokenProviderfrom DI. This provider gives you a token tied to the currentHttpContextorCancellationToken.Noneif no request is active. We originally chose this dependency injection pattern to add cancellation support without breaking existing method signatures.The Problem
While this approach avoided breaking changes, it has some clear downsides that many of you may have encountered:
CancellationTokenfor a specific operation, for example, to implement a custom timeout.CancellationToken.None, which makes it impossible to cancel these operations gracefully.The Proposal
We propose to refactor our async APIs to accept an optional
CancellationTokenparameter directly and remove theICancellationTokenProvidercompletely.We think this would be more intuitive and align with standard .NET practice. It would solve the problems mentioned above and give you control over cancellation.
The Big Trade-Off: Breaking Changes
Adding these parameters would be a major breaking change. Anyone implementing our interfaces or overriding async virtual methods of our default implementations would need to update their code to add the new parameter. This could have a cascading effect on your code.
We Need Your Feedback! 🤔
This is where you come in. We want to understand the real-world impact before we commit to such a large change.
ICancellationTokenProviderbeen a problem for you? If so, can you share a specific scenario?CancellationTokenusage worth the pain of the breaking changes?We appreciate you taking the time to share your thoughts. Your feedback will directly influence the future direction of IdentityServer!
Beta Was this translation helpful? Give feedback.
All reactions