[Feature Request] The cache serialization callbacks should accept CancellationToken
See original GitHub issueEven though the cache serialization callbacks return a Task
, they do not accept a CancellationToken
. Example is the SetBeforeAccessAsync
Accepting a CancellationToken
as a parameter is important as partners onboard to distributed caches and invoke the MSAL APIs with a CancellationToken at the ExecuteAsync API.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
[Feature Request] In-memory shared cache cache in MSAL ...
implemeting cache serialization using the callbacks is easy to get wrong and isn't even the fully documented anymore (Microsoft.Identity.Web ...
Read more >A Deep Dive into C#'s CancellationToken | by Mitesh Shah
Now whenever the source requests a cancellation, the registered callback will be called and cancellation occurs.
Read more >Register callbacks for cancellation requests
If cancellation has already been requested when the callback is registered, the callback is still guaranteed to be called. In this particular ...
Read more >CancellationToken vs CancellationChangeToken
The cancellation propagates to all cache entries that track the corresponding change token, and thus invalidates them all at once. Share.
Read more >Scripting API: ISerializationCallbackReceiver
Interface to receive callbacks upon serialization and deserialization. Unity's serializer is able to serialize most datatypes, but not all of them.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think Id.Web does consume it. The code is somewhat unclear, because we exposed an abstract class there and we chose to extend it using the “CacheSerializationHints” object, which contains the token. For example see https://github.com/AzureAD/microsoft-identity-web/blob/34325b3ae90fa84763a78ee454a3080bb07ae92f/src/Microsoft.Identity.Web.TokenCache/Distributed/MsalDistributedTokenCacheAdapter.cs#L261
Lessons learned:
@rymeskar - If you look at the
TokenCacheNotificationArgs
, you’ll see a cancellation token there. This is the cancellation token that was given viaAcquireToken***.ExecuteAsync(cancellationToken)
.I agree that it would have been better to have
SetBeforeAccessAsync
with a cancellationToken from the start. But we didn’t, so we had to add it later.The reason why we didn’t add an overload for
SetBeforeAccessAsync
this is because the callback are part of an interfaceITokenCache
, and we can’t ADD a method to an interface. Note that since we still have to support .net classic, we can’t use default interface methods. Thoughts?