Repository navigation
Keep a coalesced clone or fetch running when the request that started it disconnects [patch] - #81
Merged
Merged
Conversation
… it disconnects [patch] The leader ran clone and fetch under its own request's RequestAborted token, so a client hanging up killed git and released every follower as failed. A clone longer than the client timeout therefore never finished, and followers got 503 no-mirror. The work now runs under IHostApplicationLifetime.ApplicationStopping and owns the leader's ticket, while each caller awaits it with its own token. FetchTimeout still bounds it through GitRunner, and host shutdown still cancels it. Fixes #44 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FM7p8BsZu36YCjPsutDXQN
|
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.



Fixes #44
What was wrong
MirrorFetcher.EnsureCurrentAsyncran the leader's clone or fetch under the leader request's ownRequestAbortedtoken. When that client hung up,GitRunnerkilled git, the leader's ticket was disposed withoutComplete(true), and every follower was released as failed. With no mirror on disk yet, followers gotUnavailable(503 no-mirror). A repository whose clone takes longer than the client timeout was never mirrored.Change
LeadAsync, underIHostApplicationLifetime.ApplicationStopping, and owns the leader's ticket. It reports the outcome to followers whether or not the leader's client is still connected..WaitAsync(requestToken). A disconnecting client stops waiting, but the work keeps running.FetchTimeout. Disposing the follower ticket moved intoFollowAsyncso ownership is explicit (this also satisfies CA2025).FetchTimeoutstill bounds the git process throughGitInvocation.TimeoutinGitRunner. Host shutdown still cancels it.MirrorFetchergains anIHostApplicationLifetimeconstructor parameter. DI already provides it under the ASP.NET Core host, and the two test builders pass a newFakeHostApplicationLifetime.Tests
New
MirrorFetcherCoalescingTests:EnsureCurrent_WhenTheLeaderDisconnectsMidClone_FinishesTheCloneForTheFollowerAsync: the leader's token is cancelled mid-clone while a follower waits. The leader getsOperationCanceledException, the clone completes, the follower getsCurrent, and there is exactly one clone. This is the issue's first acceptance criterion.EnsureCurrent_WhenTheHostStopsMidClone_CancelsTheCloneAsync:StopApplication()mid-clone cancels the git invocation. This is the second criterion. Kill-on-cancel is already pinned byGitRunnerTests.I reverted the fix locally and ran both tests: both fail. Restored, both pass. Full suite: 243/243 pass on .NET 10.0.401 (Linux).
🤖 Generated with Claude Code
https://claude.ai/code/session_01FM7p8BsZu36YCjPsutDXQN
Generated by Claude Code