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.

logoutRedirect() gives --> "Error - Attempted to clear all MSAL cache items and failed. Local cache unchanged."

See original GitHub issue

Core Library

MSAL.js v2 (@azure/msal-browser)

Core Library Version

2.22.0

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

2.1.1

Description

Everything seems to be working fine, but when you do msalService.logoutRedirect() you will get an error (in Chrome browser console + preserve logs): “Error - Attempted to clear all MSAL cache items and failed. Local cache unchanged.”.

After some research I managed to find out the there it at least a “not a function” exception in CryptoOps.ts when doing databaseStorage.deleteDatabase():

typeerror

Error Message

  1. Error - Attempted to clear all MSAL cache items and failed. Local cache unchanged.
  2. databaseStorage.deleteDatabase is not a function

Msal Logs

No response

MSAL Configuration

auth: {
      clientId: <myappid>,
      authority: `https://login.microsoftonline.com/${<mytenantid>}`,
      redirectUri: '<myredirecturl>',
      postLogoutRedirectUri: '<mylogouturl>',
      navigateToLoginRequestUrl: false
    },
    cache: {
      cacheLocation: BrowserCacheLocation.LocalStorage,
      storeAuthStateInCookie: false,
    },
    system: {
      loggerOptions: {
          logLevel: LogLevel.Error,
          loggerCallback: (level, message) => {
              console.log(level, message);
          },
          piiLoggingEnabled: false
      }
    }

Relevant Code Snippets

msalService.logoutRedirect();

Reproduction Steps

  1. Open Chrome developer tools
  2. Open console
  3. Toggle “preserve logs”
  4. msalService.LoginRedirect();
  5. msalService.logoutRedirect();
  6. See the console output for error.

Expected Behavior

  1. databaseStorage.deleteDatabase() should not cause “is not a function”
  2. logoutRedirect() should not cause an error message

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

Chrome

Regression

No response

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
pkanher617commented, Mar 7, 2022

@mettoware We were able to reproduce this and hope to have a PR up to fix this shortly - thanks for bringing this to our attention!

0reactions
msftbot[bot]commented, Apr 4, 2022

🎉This issue was addressed in #4617, which has now been successfully released as @azure/msal-browser@v2.23.0.🎉

Handy links:

Read more comments on GitHub >

github_iconTop Results From Across the Web

logout method not clearing credentials from cache #2123
Is there a way to invalidate the session on the server when a user logs out? What is otherwise the purpose of calling...
Read more >
MSAL sign out does not appear to clear cache - Microsoft Learn
We have an android application integrated with azure authentication using MSAL and it's configured to be single tenant.
Read more >
How to Clear the cache token in MSAL SPA? - Stack Overflow
I don't think that's MSAL that is caching there, it's Azure AD. You can specify a prompt query parameter to the request to...
Read more >
Five Gotchas while using MSAL with Azure AD
Incorrect Scope specified, got error after login. Resolution. When we specify the scopes of our APIs, make sure we specify complete URI.
Read more >
PublicClientApplication | microsoft-authentication-libraries-for-js
Returns all accounts that MSAL currently has data for. (the account object is created at the time of successful login) or empty array...
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