Repository navigation
Conversation
When a cached token expires, every GCM process that needs it (for example one per Git worktree, or one per parallel fetch) falls back to interactive authentication on its own. They share one MSAL token cache, so only one sign-in is needed, but after it completes the other processes never look at the cache again and keep prompting or waiting. Take a per-client, per-authority lock file in the GCM data directory before starting an interactive or broker flow. Once the lock is held, resolve the account again and retry silent authentication, so a token stored by another process is used without a second prompt. Waiting honours cancellation and gives up after five minutes. If the lock cannot be taken, authentication continues as before. Verified with four parallel `get` requests against an expired account: before, four device-code flows started; now one starts and three wait. Assisted-by: Claude Sonnet 5.5 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
cveld
marked this pull request as ready for review
October 13, 2026 11:46
This branch has not been deployed
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.
Problem
When a cached token expires, every GCM process that needs it (one per Git worktree, one per parallel fetch, an IDE autofetch, ...) falls back to interactive authentication on its own. They share one MSAL token cache, so one sign-in is enough, but after it completes the other processes never look at the cache again. They keep prompting or waiting. In one environment a single token expiry left 189 stray
git fetch/git-credential-manager getprocesses behind.Discussed in #1555 (see my two comments there) and related to #2288.
Change
In
EntraAuthentication.GetTokenForUserAsync, after silent authentication fails and interaction is allowed:entra-signin-<hash>.lockin the GCM data directory (hash of client ID, authority and cache type).Waiting honours cancellation and gives up after 5 minutes. If the lock cannot be taken, authentication continues exactly as before. A file handle is used rather than a named mutex (thread affinity across
await); the OS releases it if the process exits.Verification
EntraAuthenticationInteractiveLockTests).dotnet testrun on Windows: everything passes except 6Trace2MessageTests.BuildTimeSpancases that fail on a Dutch locale (decimal comma) onmainas well; they pass withDOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1.getprocesses for an account missing from the cache (GCM_MSAUTH_FLOW=devicecode):mainstarts 4 device-code flows, this branch starts 1 and the other 3 wait.Not verified
Opened as a draft: the maintainers have said serialization is planned for 3.0, so this is meant as a concrete proposal to react to.
🤖 Generated with Claude Code