Repository navigation
fix(server): a failed or cancelled clone no longer blocks re-cloning its destination #40739
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -297,14 +297,19 @@ export const make = Effect.gen(function* () { | |
| endedAt: null, | ||
| sequence: ++sequence, | ||
| }; | ||
| const claimed = yield* Ref.modify(clones, (current) => { | ||
| const conflict = Array.from(current.values()).some( | ||
| const claim = yield* Ref.modify(clones, (current) => { | ||
| const overlapping = Array.from(current.values()).filter( | ||
| (tracked) => | ||
| tracked.snapshot.projectId === input.projectId || | ||
| tracked.input.destinationPath === prepared.destinationPath, | ||
| ); | ||
| if (conflict) return [false, current] as const; | ||
| // Only a running clone owns its destination; a failed or cancelled one | ||
| // left nothing behind, so a fresh start supersedes it. | ||
| if (overlapping.some((tracked) => tracked.snapshot.phase === "running")) { | ||
| return [null, current] as const; | ||
| } | ||
| const next = new Map(current); | ||
| for (const stale of overlapping) next.delete(stale.snapshot.projectId); | ||
| next.set(input.projectId, { | ||
| snapshot, | ||
| fiber: null, | ||
|
|
@@ -316,14 +321,16 @@ export const make = Effect.gen(function* () { | |
| protocol: input.protocol ?? "auto", | ||
| }, | ||
| }); | ||
| return [true, next] as const; | ||
| return [overlapping.map((stale) => stale.snapshot.projectId), next] as const; | ||
| }); | ||
| const alreadyInProgress = new SourceControlRepositoryError({ | ||
| operation: "cloneRepository", | ||
| provider: input.provider ?? SourceControlProviderKind.make("unknown"), | ||
| detail: "A clone into this destination is already in progress.", | ||
| }); | ||
| if (!claimed) return yield* alreadyInProgress; | ||
| if (claim === null) return yield* alreadyInProgress; | ||
| // A superseded done entry's pending removal would otherwise delete the new claim. | ||
| yield* Effect.forEach(claim, clearRetention, { discard: true }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A due retention timer can remove the replacement claim before
Retention removal must delete only the entry it scheduled. Cancelling the timer at line 333 does not close this window, because the claim is already committed when the cancellation runs.
|
||
| // Finish or release the claim despite disconnects; a claim without a fiber cannot be cancelled or retried. | ||
| const projectId = yield* Effect.uninterruptible( | ||
| Effect.gen(function* () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait for clone milestones instead of scheduler turns.
Effect.yieldNowdoes not identify completion offinishoronCloned. The assertions therefore depend on scheduling.Subscribe to the expected tracker phase before starting each attempt. Await
onClonedseparately before checkingharness.cloned. Remove the unnecessary yield from the running-clone test.As per coding guidelines, “drain the effect worker … or await the specific persisted event or
Deferredthat marks the milestone.” As per path instructions, changed tests must follow those synchronization rules.Also applies to: 356-356, 368-368
Sources: Coding guidelines, Path instructions