AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS
http://aka.ms/aadv2
MIT License
3.68k stars 2.65k forks source link

Getting TypeError: eventTypes.includes is not a function #7377

Open itsthamarai opened 1 month ago

itsthamarai commented 1 month ago

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.0.2

Wrapper Library

MSAL React (@azure/msal-react)

Wrapper Library Version

2.0.2

Public or Confidential Client?

Public

Description

Hi Team - I have started seeing the error - TypeError: eventTypes.includes is not a function in the last few days in our test environments, though higher environments does not have this issue.

Error Message

TypeError: a.includes is not a function at EventHandler.ts:99:36 at Map.forEach () at _c.emitEvent (EventHandler.ts:89:33) at Il.initialize (StandardController.ts:341:27) at Ol.initialize (PublicClientApplication.ts:95:32) at index.js:85:6 at f (authentication.js:102:3) at index.js:17:1 at index.js:158:7 at index.js:158:7

MSAL Logs

There are no MSAL logs in the console

Network Trace (Preferrably Fiddler)

MSAL Configuration

export const msalConfig = {
    auth: {
        clientId: XXXXXXX,
        authority: `https://login.microsoftonline.com/XXXXXXX`,
        redirectUri: window.location.origin,
        knownAuthorities: ["login.microsoftonline.com"],
        navigateToLoginRequestUrl: true,
        postLogoutRedirectUri: window.location.origin,
    },
    cache: {
        cacheLocation: "sessionStorage", // This configures where your cache will be stored
        storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
        secureCookies: true,
        cacheMigrationEnabled: true,
    },
    system: {   
        loggerOptions: {    
            loggerCallback: (level, message, containsPii) => {  
                if (containsPii) {      
                    return;     
                }       
                switch (level) {
                    case LogLevel.Error:
                        console.error(message);
                        return;
                    case LogLevel.Info:
                        console.info(message);
                        return;
                    case LogLevel.Verbose:
                        console.debug(message);
                        return;
                    case LogLevel.Warning:
                        console.warn(message);
                        return;
                    default:
                        return;
                }   
            }   
        }   
    }
};

Relevant Code Snippets

msalInstance
        .initialize()
        .then((res) => {
          // handle auth redirect/do all initial setup for msal
          msalInstance
            .handleRedirectPromise()
            .then((authResult) => {
              // redirect anonymous user to login page
              msalInstance.loginRedirect();
              const accounts = msalInstance.getAllAccounts();
              msalInstance.setActiveAccount(accounts[0]);
            })
            .catch((err) => {
              console.log(err);
            });
        })
        .catch((err) => {
          console.log(err);
        });

Reproduction Steps

I see a blank screen instead of the login screen when navigating to the app url

Expected Behavior

The login page should be displayed when there is no active account or The App Home page should be displayed when there is an active account.

Identity Provider

Entra ID (formerly Azure AD) / MSA

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge

Regression

"@azure/msal-browser": "3.0.2"

johannesleite commented 3 weeks ago

same issue here, didn't do any MSAL upgrades but it just started happening

tony-gutierrez commented 6 days ago

Same issue.