Skip to content

Login Popup doesn't have any event on pop up close by user ends up into timeout error #8521

@amolkurhe87

Description

@amolkurhe87

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

5.6.1

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

None

Public or Confidential Client?

Confidential

Description

Recently, we have migrated to 5.x and using msal-browser (5.6.1) version. We have implemented redirect bridge to handle popup communication as per COOP requirements.

When user clicks on sign in and on popup is opened, if user cancel it there is no updates post through event callback and sign in flow is blocked as interaction status is still in progress.
It takes more than 60s and ends up in the timeout error.

Is there alternate option to handle this scenario with v5.x while following COOP requirements? Am I missing anything her

Error Message

Error Message: Uncaught (in promise) BrowserAuthError: timed_out: See https://aka.ms/msal.js.errors#timed_out for details

Stack trace Details:
BrowserAuthError: timed_out
at BrowserAuthError.createMonitorWindowTimeoutError
at PopupHandler.monitorPopupForHash
(PopupHandler.ts)
at PopupClient.acquireTokenPopupAsync
(PopupClient.ts)
at StandardInteractionClient.acquireToken
(StandardInteractionClient.ts)
at PublicClientApplication.acquireTokenPopup
(PublicClientApplication.ts)
at PublicClientApplication.loginPopup
(PublicClientApplication.ts)

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

{
    auth: {
        clientId: '',
        authority: 'https://login.microsoftonline.com/common/',
        redirectUri: '<domain>/redirect',
    },
    cache: {
        cacheLocation: BrowserCacheLocation.LocalStorage
    }

Relevant Code Snippets

private async runAuthExclusive<T>(fn: () => Promise<T>): Promise<T> {
        if (this.pendingAuth) {
            try { await this.pendingAuth; } catch { }
        }
        const p = fn();
        this.pendingAuth = p;
        try {
            return await p;
        } finally {
            if (this.pendingAuth === p) this.pendingAuth = null;
        }
    }

public async signIn(authParams: any) {
        return this.runAuthExclusive(async () => {
            try {
                const response = await this.msalInstance.loginPopup({
                    ...authParams,
                    prompt: authParams.prompt ?? "select_account",
                    redirectUri: this.getPopupRedirectUri()
                });

                if (response?.account) {
                    this.setCurrentAccount(response.account);
                }
            } catch (e: any) {
                
                if (e instanceof BrowserAuthError && e.errorCode === "popup_window_error") {
                    await this.msalInstance.loginRedirect({
                        ...authParams,
                        prompt: authParams.prompt ?? "select_account",
                        redirectUri: this.getRedirectUri(),
                        redirectStartPage: window.location.href
                    });
                    return;
                }

                throw e;
            }
        });
    }

Reproduction Steps

  1. Load UHF Me control on the page.
  2. Set Me Control Configuration and pass signIn.bind(authModule) instance to me control config.
  3. Set other configuration settings for MeControl as needed.
  4. Run the application.

Expected Behavior

On Pop up close by user, there should an immediate updates to the caller/parent window or an event update to perform other operations like clear popup settings and unblock sign in flow UI interaction.

Identity Provider

Entra ID (formerly Azure AD) / MSA

Browsers Affected (Select all that apply)

Chrome, Edge, Firefox

Regression

@azure/msal-browser(3.x)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-unconfirmedA reported bug that needs to be investigated and confirmedconfidential-clientIssues regarding ConfidentialClientApplicationsmsal-angularRelated to @azure/msal-angular packagemsal-browserRelated to msal-browser packagequestionCustomer is asking for a clarification, use case or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions