AzureAD / microsoft-authentication-library-for-js

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

MSAL Client stopped working after release of msal-common 9.0.2 #5569

Closed AnkHansen closed 1 year ago

AnkHansen commented 1 year ago

Core Library

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

Core Library Version

2.32.1

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

2.5.1

Public or Confidential Client?

Public

Description

We had a working setup, then yesterday when we build a release version on our CI pipeline the released product crashed whenever we tried to login with the PublicClientApplication.

Calling either LoginRedirect or AcquireTokenPopup caused the exception posted below in Error Message.

Nothing in our code base had changed from the solution working to crashing with this.

Workaround is to set reference to @Azure/msal-common 9.0.1 in package.json - then everything seems to work again.

In yesterdays package.json @azure/msal-common was not mentioned, and it seems @Azure/msal.angular usees ^9.0.0 to look up common.

Picking an explicit version seems to fix the problem.

But still 9.0.2 seems broken from where I stand.

Error Message

Error: Uncaught (in promise): TypeError: this.startPerformanceMeasurement is not a function TypeError: this.startPerformanceMeasurement is not a function at o.startMeasurement (PerformanceClient.js:50:1) at t.startMeasurement (BrowserPerformanceClient.js:43:1) at t. (StandardInteractionClient.js:221:1) at d (_tslib.js:87:1) at Object.next (_tslib.js:68:46) at _tslib.js:61:1 at new n (zone.js:1429:1) at to (tslib.js:57:1) at t.getDiscoveredAuthority (StandardInteractionClient.js:215:16) at t. (StandardInteractionClient.js:155:1) at z (zone.js:1211:1) at zone.js:1118:1 at zone.js:1134:1 at Lve (asyncToGenerator.js:6:1) at s (asyncToGenerator.js:29:1) at k.invoke (zone.js:372:1) at Object.onInvoke (core.mjs:25608:1) at k.invoke (zone.js:371:1) at .run (zone.js:134:1) at zone.js:1275:1

Msal Logs

No response

MSAL Configuration

{
    auth: {
         clientId: azureAD.clientId,
         authority: "https://login.microsoftonline.com/" + azureAD.tenantId,
    },
    cache: {
         cacheLocation: 'localStorage',
    },
}

LoginRedirect request
{
    authority: "https://login.microsoftonline.com/" + azureAD.tenantId,
    redirectUri: window.location.origin + "/login",
    scopes: ["api://" + azureAD.clientId + "/access"],
    prompt: 'select_aacount
}

Relevant Code Snippets

const azureClient = this.authenticationService.getAzureClient();

await azureClient.handleRedirectPromise();

await azureClient.loginRedirect(this.authenticationService.getAzureRedirectRequest());

 public getAzureClient(): IPublicClientApplication {
        const azureAD = this.authenticationIntegration?.azureAD;
        if (azureAD?.useAzureAD) {
            if (Object.isNullOrUndefined(this._azureClient)) {
                this._azureClient = new PublicClientApplication({
                    auth: {
                        clientId: azureAD.clientId,
                        authority: "https://login.microsoftonline.com/" + azureAD.tenantId,
                    },
                    cache: {
                        cacheLocation: 'localStorage',
                    },
                });
            }
            return this._azureClient;
        } else {
            return undefined;
        }
    }

public getAzureRedirectRequest(): RedirectRequest {
        const azureAD = this.authenticationIntegration.azureAD;
        const prompt = azureAD.attemptAutomaticLogin ? undefined : 'select_account';

        return {
            authority: "https://login.microsoftonline.com/" + azureAD.tenantId,
            redirectUri: window.location.origin + "/login",
            scopes: ["api://" + azureAD.clientId + "/access"],
            prompt: prompt
        }
    }

Reproduction Steps

Build with package json using these three

"@azure/msal-browser": "2.32.1", "@azure/msal-angular": "2.5.1", "@azure/msal-common": "9.0.1",

Things are working.

Build with "@azure/msal-browser": "2.32.1", "@azure/msal-angular": "2.5.1", "@azure/msal-common": "9.0.2",

things are broken

Expected Behavior

That you releasing a fix version to msal-common doesn't break our production build ;-)

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

Chrome, Edge

Regression

@azure/msal-common 9.0.1

Source

External (Customer)

jo-arroyo commented 1 year ago

@AnkHansen This is a bug with the previous release, and we are currently working on a fix. Please downgrade until the fix is released.

yassarikhan786 commented 1 year ago

Hi all, I've tried explicitly adding "@azure/msal-common": "^9.0.1", to my package.json with no success. The difference with my project is that I'm using "@azure/msal-react".

I've tried downgrading the version of msal-react with no success. Any suggestions would be welcome. My setup is as follows:

    "@azure/msal-browser": "^2.32.0",
    "@azure/msal-common": "^9.0.1",
    "@azure/msal-react": "^1.4.10",
ralphtheninja commented 1 year ago

Hi all, I've tried explicitly adding "@azure/msal-common": "^9.0.1", to my package.json with no success. The difference with my project is that I'm using "@azure/msal-react".

@yassarikhan786 This means you'll get version 9.0.2 which is what you don't want. You should pin it to 9.0.1 and not use ^.

yassarikhan786 commented 1 year ago

Hi @ralphtheninja thank you for that. I've tried that and unfortunately it doesn't work. It works locally and fails when deployed. I'm deploying to an azure website. Build and Release pipelines are fine.

yassarikhan786 commented 1 year ago

If it helps anyone, I ended up with the following in my package.json:

    "@azure/msal-browser": "2.32.0",
    "@azure/msal-common": "9.0.1",
    "@azure/msal-react": "1.5.0",

Thanks to @ralphtheninja for suggesting I should get rid of the ^

I also updated the npm install command in the Azure Pipeline yaml to be npm install --legacy-peer-deps

aneeshm-kroger commented 1 year ago

Hi I am using react and i have this setup:
"@azure/msal-browser": "^2.31.0", "@azure/msal-react": "^1.5.0", I am getting below error , please help me out about this : PerformanceClient.ts:123 Uncaught (in promise) TypeError: a.startMeasurement is not a function at e.startMeasurement (PerformanceClient.ts:123:32) at t.startMeasurement (BrowserPerformanceClient.ts:46:55) at t. (StandardInteractionClient.ts:205:65) at Navbar.js:82:11 at Object.next (Navbar.js:82:11) at Navbar.js:82:11 at new Promise () at _l (Navbar.js:82:11) at t.getDiscoveredAuthority (StandardInteractionClient.ts:203:71) at t. (StandardInteractionClient.ts:142:48)

Screenshot 2023-01-19 at 8 00 26 AM
heerparmar commented 1 year ago

Same issue we are facing in live, local it's working,

Try to update version as below, It is working for us.

 "@azure/msal-browser": "2.30.0",    
 "@azure/msal-common": "7.6.0",
 "@azure/msal-react": "1.4.5"

Thanks

aneeshm-kroger commented 1 year ago

Now I am using this one still I am getting same error: "@azure/msal-browser": "^2.30.0", "@azure/msal-common": "^7.6.0", "@azure/msal-react": "^1.4.5" Error: PerformanceClient.ts:123 Uncaught (in promise) TypeError: a.startMeasurement is not a function at e.startMeasurement (PerformanceClient.ts:123:32) at t.startMeasurement (BrowserPerformanceClient.ts:46:55) at t. (StandardInteractionClient.ts:205:65) at Navbar.js:82:11 at Object.next (Navbar.js:82:11) at Navbar.js:82:11 at new Promise () at _l (Navbar.js:82:11) at t.getDiscoveredAuthority (StandardInteractionClient.ts:203:71) at t. (StandardInteractionClient.ts:142:48)

heerparmar commented 1 year ago

Hi @aneeshm-kroger Do not add ^ before version, delete entire node_modules folder, package-lock.json or yarn.lock file and check, Hope it will resolve your issue.

Thanks

aneeshm-kroger commented 1 year ago

Hi @aneeshm-kroger Do not add ^ before version, delete entire node_modules folder, package-lock.json or yarn.lock file and check, Hope it will resolve your issue.

Thanks

Many many Thanks Its working for me

dlgoodchild commented 1 year ago

I've just hit this problem also, and can confirm that @yassarikhan786 suggested versions work.

jo-arroyo commented 1 year ago

Thank you all for your patience. Msal-common v 9.1.1 has been released. Please upgrade and let us know if you continue to see issues.

davidspiess commented 1 year ago

@jo-arroyo 9.1.1 fixes the issue for me

dlgoodchild commented 1 year ago

I can also confirm that the following package versions work:

    "@azure/msal-browser": "^2.32.2",
    "@azure/msal-common": "^9.1.1",
    "@azure/msal-react": "^1.5.2",
jo-arroyo commented 1 year ago

Thank you for the confirmation. Closing as msal-common v9.1.1 release addresses these issues. Please open a new issue if you continue to see errors.