Skip to content
TypeScript

fix(server): tracked clones keep an explicit SSH protocol on fallback and Retry (#28365)

Victor Vogeldcbe9a6f890a
diff --git a/apps/server/src/project/ProjectCloneTracker.test.ts b/apps/server/src/project/ProjectCloneTracker.test.ts
index 6a13af9ef94..ed775e55a98 100644
--- a/apps/server/src/project/ProjectCloneTracker.test.ts
+++ b/apps/server/src/project/ProjectCloneTracker.test.ts
@@ -4,6 +4,7 @@ import {
OrchestrationDispatchCommandError,
ProjectId,
projectCloneProgressSummary,
+ type SourceControlCloneProtocol,
SourceControlRepositoryError,
} from "@t3tools/contracts";
import * as Deferred from "effect/Deferred";
@@ -146,12 +147,12 @@ describe("ProjectCloneTracker", () => {
});
it.effect("keeps a failed clone with git's own explanation and retries it", () => {
- let attempts = 0;
+ const protocols: Array<SourceControlCloneProtocol | undefined> = [];
const harness = makeHarness({
clone: (input) =>
Effect.suspend(() => {
- attempts += 1;
- return attempts === 1
+ protocols.push(input.protocol);
+ return protocols.length === 1
? Effect.fail(
new SourceControlRepositoryError({
operation: "cloneRepository",
@@ -168,7 +169,7 @@ describe("ProjectCloneTracker", () => {
});
return Effect.gen(function* () {
const tracker = yield* ProjectCloneTracker.ProjectCloneTracker;
- yield* tracker.start(startInput, harness.hooks);
+ yield* tracker.start({ ...startInput, protocol: "ssh" }, harness.hooks);
yield* Effect.yieldNow;
const failed = yield* tracker.get(projectId);
expect(failed).toMatchObject({ phase: "failed", error: "fatal: repository not found" });
@@ -177,7 +178,7 @@ describe("ProjectCloneTracker", () => {
expect(harness.discarded).toEqual(["/workspace/t3code"]);
yield* Effect.yieldNow;
expect((yield* tracker.get(projectId))?.phase).toBe("done");
- expect(attempts).toBe(2);
+ expect(protocols).toEqual(["ssh", "ssh"]);
}).pipe(Effect.provide(harness.layer));
});
diff --git a/apps/server/src/project/ProjectCloneTracker.ts b/apps/server/src/project/ProjectCloneTracker.ts
index 4a0c9979515..0a512bde2aa 100644
--- a/apps/server/src/project/ProjectCloneTracker.ts
+++ b/apps/server/src/project/ProjectCloneTracker.ts
@@ -5,6 +5,7 @@ import type {
ProjectCloneStartInput,
ProjectCloneStartResult,
ProjectId,
+ SourceControlCloneProtocol,
SourceControlRepositoryInfo,
} from "@t3tools/contracts";
import {
@@ -85,6 +86,7 @@ interface TrackedClone {
readonly cloneUrl: string;
readonly destinationPath: string;
readonly repository: SourceControlRepositoryInfo | null;
+ readonly protocol: SourceControlCloneProtocol;
};
}
@@ -216,7 +218,11 @@ export const make = Effect.gen(function* () {
const pulses = yield* Queue.sliding<void>(1);
yield* watchForStall(projectId, pulses).pipe(Effect.forkScoped);
return yield* repositories.cloneRepository(
- { remoteUrl: tracked.input.cloneUrl, destinationPath: tracked.input.destinationPath },
+ {
+ remoteUrl: tracked.input.cloneUrl,
+ destinationPath: tracked.input.destinationPath,
+ protocol: tracked.input.protocol,
+ },
{
onProgress: (update) =>
Queue.offer(pulses, undefined).pipe(Effect.andThen(progress(projectId, update))),
@@ -295,6 +301,7 @@ export const make = Effect.gen(function* () {
cloneUrl: prepared.cloneUrl,
destinationPath: prepared.destinationPath,
repository: prepared.repository,
+ protocol: input.protocol ?? "auto",
},
});
return [true, next] as const;