question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] SuggestedCacheExpiry can be in the past and results in System.ArgumentOutOfRangeException: The relative expiration value must be positive.

See original GitHub issue

A customer reported this issue with their InMemory OBO cache.

full exception:

System.ArgumentOutOfRangeException: The relative expiration value must be positive. (Parameter 'AbsoluteExpirationRelativeToNow')
Actual value was -18869.20:47:50.7160847.

Could be that there was an old cache with an expired token, and the expiry computed by MSAL was done in an older version, the newer version of MSAL no longer computes the expiry for OBO tokens, so the cache doesn’t know how to process it. not sure, needs to be investigated. Have not been able to repro locally.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
bgavrilMScommented, Feb 9, 2022

Hi @petrochuk - the “sequence contains no elements” is a different problem. The tracking issue for it is: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/3130

I have a PR out of it and we’re going to hotfix MSAL, most likely in a day or two. I expect MSAL 4.41.1 to have the fix.

1reaction
bgavrilMScommented, Aug 31, 2021

What’s possibly happening is that CalculateSuggestedCacheExpiry is called in the finally clause.

So if an exception occured (e.g. during serialization to Redis), we still try to compute the cache expiry, but we will have not added a tokens to the cache. We should check if we indeed added them?

Read more comments on GitHub >

github_iconTop Results From Across the Web

The relative expiration value must be positive · Issue #1419 ...
moving from Id web 1.15 to 1.16, a few reports of the SuggestedCacheExpiry form MSAL being a negative value with the OBO token...
Read more >
LazyCache prevent null items being added to cache
Your code throws to me an ArgumentOutOfRangeException: The relative expiration value must be positive. on the line that assigns the entry.
Read more >
AbpMemoryCacheManager Error #5063 | Support Center
System.ArgumentOutOfRangeException: The relative expiration value must be positive. Parameter name: AbsoluteExpirationRelativeToNow. Actual ...
Read more >
FIX: Expiration time issue when you insert items by using ...
Fixes an issue in which items that are inserted into the Cache object by using the "Cache.Insert" method expire much earlier or later...
Read more >
Expiration - requests-cache 1.1.0 documentation
By default, cached responses will be stored indefinitely. There are a number of options for specifying how long to store responses, either with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found