Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] DurationTotalInMs in AuthenticationResultMetadata seems to differ from a Stopwatch measured call #4895

Open
zachcwillson opened this issue Aug 14, 2024 · 0 comments

Comments

@zachcwillson
Copy link

Library version used

4.63.0

.NET version

net8.0-windows10.0.22621.0, latest patch

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, I haven't upgraded MSAL, but started seeing this issue

Issue description and reproduction steps

We observe that the time measurement reported from AuthenticationResultMetadata is not accurate.
image

Relevant code snippets

private static readonly BrokerOptions WamBrokerOptions = new(BrokerOptions.OperatingSystems.Windows);
var publicClient = PublicClientApplicationBuilder
    .Create("{{clientId}}")
    .WithBroker(WamBrokerOptions)
    .WithAuthority(AzureCloudInstance.AzurePublic, AadAuthorityAudience.AzureAdMultipleOrgs)
    .WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
    .Build();

var start = Stopwatch.GetTimestamp();
var authenticationResult = await publicClient
    .AcquireTokenSilent(scopes, PublicClientApplication.OperatingSystemAccount)
    .ExecuteAsync();
var duration = Stopwatch.GetElapsedTime(start);

Console.WriteLine($"DurationTotalInMs: {authenticationResultMetadata.DurationTotalInMs}");
Console.WriteLine($"Stopwatch Measured in ms: {duration.TotalMilliseconds}");

Expected behavior

We expect the Stopwatch measured duration and the DurationTotalInMs to be closer to actual.

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

No response

@zachcwillson zachcwillson added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels Aug 14, 2024
@bgavrilMS bgavrilMS added bug P2 WAM and removed untriaged Do not delete. Needed for Automation needs attention Delete label after triage labels Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants