Skip to content

Conversation

@mogzol
Copy link
Contributor

@mogzol mogzol commented Jan 15, 2026

Changes

When useMrrt is enabled and the library is retrieving a token from the cache, it will now handle the case where the requested audience has a key in the cache, but the value is undefined. Previously this would cause an issue where the library would fail to try using the refresh token from other cache entries. See #1507.

References

Fixes #1507.

Testing

  • This change adds unit test coverage
  • This change adds integration test coverage
  • This change has been tested on the latest version of the platform/language

Checklist

@mogzol mogzol requested a review from a team as a code owner January 15, 2026 00:31
When `useMrrt` is enabled and you call `getTokenSilently` for an
audience that isn't in the cache, the library will use a refresh token
from a different entry in the cache to fetch the new token. But, if you
called `getTokenSilently` for an audience who's key is in the cache, but
who's value returns `undefined`, then it would not do this, it would
just return a MissingRefreshTokenError.

To fix this, the code has been modified to check the value retrieved
from the cache, rather than just checking whether the key exists.

The cache returning undefined for an existing key is valid behavior and
could even be likely if using a custom cache implementation. Even with
the standard cache though, it could still happen if the cache entry is
deleted between the keys being fetched and the value being fetched. Or
if the cache value has been corrupted somehow, and doesn't parse to
valid JSON.
@mogzol mogzol force-pushed the fix-mrrt-cache-undefined branch from 1dbb0bd to a14236d Compare January 15, 2026 01:56
Copy link
Contributor

@yogeshchoudhary147 yogeshchoudhary147 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this fix works correctly. Tested the scenario where a cache entry
exists but returns undefined (corrupted JSON). The library now properly
falls back to using refresh tokens from other cache entries instead of
throwing MissingRefreshTokenError.

✅ Test passed with the fix applied.

@yogeshchoudhary147 yogeshchoudhary147 merged commit a593edf into auth0:main Jan 15, 2026
10 of 13 checks passed
yogeshchoudhary147 added a commit that referenced this pull request Jan 16, 2026
**Fixed**
- fix: add two-tier locking to prevent iframe race conditions causing
"Invalid state" errors
[\#1505](#1505)
([yogeshchoudhary147](https://github.com/yogeshchoudhary147))
- fix: handle undefined value when finding MRRT refresh token
[\#1508](#1508)
([mogzol](https://github.com/mogzol))
- fix: update refresh token in all cache entries on rotation
[\#1503](#1503)
([gyaneshgouraw-okta](https://github.com/gyaneshgouraw-okta))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When MRRT is enabled, if a cache entry returns undefined, the library will not use the refresh token from other cache entries

2 participants