Repository navigation
Conversation
…onService callers EnsureAuthService only set its flag after awaiting AuthenticationService.init, so callers that overlap during startup (the authentication state and an access token request, for example) each called init in JS. The MSAL interop doesn't dedupe those calls, which loses the login return URL after a redirect sign-in. Cache the initialization task so concurrent callers await the same call. A failed initialization isn't cached, so the next caller retries, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Thanks for your PR, @droyad. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused task-caching change preserves retry semantics and has deterministic unit coverage.
0 open findings
What changed in this PR
Caches authentication initialization so overlapping callers share one JavaScript invocation while failures remain retryable.
Changes:
- Replaces the initialization flag with a shared initialization task.
- Adds deterministic concurrency and failure-retry tests.
| File | Description |
|---|---|
RemoteAuthenticationService.cs |
Shares and resets the JavaScript initialization task. |
RemoteAuthenticationServiceTests.cs |
Covers concurrent initialization and retry behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 9, 2026
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Share a single JS initialization across concurrent RemoteAuthenticationService callers
Initialize the authentication JS service once, even when callers overlap
Description
RemoteAuthenticationService.EnsureAuthService()checks abooland only sets it after awaitingAuthenticationService.init. During startup, callers overlap (for exampleGetAuthenticationStateAsyncand an access token request fromBaseAddressAuthorizationMessageHandler), so each one callsinitin JS.The OIDC interop already dedupes concurrent
initcalls with a cached promise. The MSAL interop doesn't since #66055, and the result is that the login return URL is lost after a redirect sign-in (#68136; root cause and trace in this comment). The companion PR #69735 fixes the MSAL interop. Either change fixes the bug on its own. This PR makes the managed side stop relying on each JS implementation to dedupe:EnsureAuthService()caches the initializationTask, so concurrent callers await the same JS call._initializedstaysfalseafter a failure.Tests
Added to
RemoteAuthenticationServiceTests:RemoteAuthenticationService_ConcurrentCalls_InitializeJavaScriptServiceOnceholdsinitopen with a test-controlledTaskCompletionSource(no sleeps), starts twoGetAuthenticatedUser()calls, then releases the gate. It asserts a singleAuthenticationService.initcall and twogetUsercalls.RemoteAuthenticationService_RetriesInitialization_AfterFailure: the firstinitfails, and the next call retries it.Red/green, running
RemoteAuthenticationServiceTestslocally:EnsureAuthServicechangeConcurrentCalls_InitializeJavaScriptServiceOncefails withAssert.Single() Failure: The collection contained 2 matching items(twoinitcalls)RetriesInitialization_AfterFailurepasses both before and after on purpose. It's a control that protects the existing retry-after-failure behaviour.This is a managed-side change: the final observable is the number of
initcalls, which these tests assert directly with a test-controlled gate. The browser-level symptom (the lost return URL) depends on the MSAL interop and Entra ID. As far as I can tell,src/Components/test/E2ETesthas no MSAL fixture, only OIDC (RemoteAuthenticationStartup), so that path isn't covered here.Fixes #68136
🤖 Generated with Claude Code