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.

Login popup doesn't close and displays react app itself

See original GitHub issue

Core Library

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

Core Library Version

2.28.1

Wrapper Library

MSAL React (@azure/msal-react)

Wrapper Library Version

1.4.5

Description

Hi, I think I’ve just found a bug in MSAL.js. I installed the latest version in two different samples for React. When I try to log in, sometimes the popup shows the React Webapp itself and doesn’t close.

  • The first sample I used was this one: https://github.com/Azure-Samples/ms-identity-javascript-react-spa FirstBug
  • And the second one was here in this repository: https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/react-18-sample SecondBug

Error Message

No response

Msal Logs

No response

MSAL Configuration

{
    auth: {
        clientId: "my_client_id",
        authority: "https://login.microsoftonline.com/...",
        redirectUri: "http://localhost:3000"
    },
    cache: {
        cacheLocation: "sessionStorage", 
        storeAuthStateInCookie: false
    },
    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;		
                }	
            }	
        }	
    }
}

Relevant Code Snippets

There is no relevant code snippet as I have only changed the MSAL configuration.

Reproduction Steps

  1. Clone the sample
  2. Install the newest version of @azure/msal-browser and @azure/msal-react through npm.
  3. Adjust MSAL configuration
  4. Run the sample and try to log in several times.

Expected Behavior

Login popup should close, but it doesn’t.

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge

Regression

@azure/msal-browser 2.15.0

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:30 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
aNyMoRe0505commented, Oct 13, 2022

I think this issue is not resolved yet, even with the blank route. As @hectormmg said, it just mitigate the race condition (?)

2reactions
tnorlingcommented, Aug 29, 2022

No this is a race condition between the popup window and the caller. The problem only surfaces when the router (or other hash clearing/redirection logic) wins the race. Check if there’s a hash with code= in the address bar of the popup window when this occurs. If there’s not, something inside the popup is removing the hash.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft Authentication Library (MSAL) loginPopup doesn't ...
Expected behavior: A login popup pops up and after the user logs in the pop up closes itself and the loginPopup promise resolves...
Read more >
Creating A PopUp Window Using JS And React - Medium
A small guide on creating the infamous “popup” window that is both a blessing and a curse for users with the help of...
Read more >
Error Boundaries - React
Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI ......
Read more >
React | IntelliJ IDEA Documentation - JetBrains
Open the application sources that are already on your machine. Click Open or Import on the Welcome screen or select File | ...
Read more >
How to Open and Close a React-Bootstrap Modal ... - Pluralsight
# Introduction · Import Components from React Bootstrap · Set up the Modal Component · Build the Login Form · Handle the onSubmit()...
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