stablyai/orca · warning · Error

A clone is already in progress for this SSH destination

Error message

A clone is already in progress for this SSH destination

What it means

Thrown when remoteCloneInFlightByPath.has(remoteCloneKey), where remoteCloneKey = `${connectionId}:${clonePathKey}`. remoteCloneInFlightByPath is a module-level Set that tracks in-flight remote clones per (connection, normalized clone path). The set is populated when a clone starts and cleared in the finally block of the clone try/catch. The guard prevents two concurrent clones writing to the same destination.

Source

Thrown at src/main/ipc/repos.ts:521

  const clonePath = joinRemotePath(host, trimmedDestination, repoName)
  if (relativePathInsideRoot(trimmedDestination, clonePath) === null) {
    throw new Error('Clone path must be inside the destination directory')
  }
  const clonePathKey = normalizeRuntimePathForComparison(clonePath)
  const existing = store.getRepos().find((repo) => {
    return (
      repo.connectionId === args.connectionId &&
      normalizeRuntimePathForComparison(repo.path) === clonePathKey
    )
  })
  if (existing && !isFolderRepo(existing)) {
    emitRepoAdded('clone_url', true)
    return existing
  }

  const remoteCloneKey = `${args.connectionId}:${clonePathKey}`
  if (remoteCloneInFlightByPath.has(remoteCloneKey)) {
    throw new Error('A clone is already in progress for this SSH destination')
  }
  const controller = new AbortController()
  const metadata: ActiveRemoteCloneMetadata = {
    connectionId: args.connectionId,
    clonePath,
    controller
  }
  activeRemoteClone = metadata
  remoteCloneInFlightByPath.add(remoteCloneKey)
  try {
    // Why: match local clone by creating the parent first, or a fresh remote parent surfaces as spawn ENOENT.
    await fsProvider.createDir(trimmedDestination)
    // Why: the SSH relay runs git argv, not a shell; use the repo folder name so git creates it under the chosen parent.
    await gitProvider.clone(
      ['clone', '--progress', '--', args.url.trim(), repoName],
      trimmedDestination,
      {
        signal: controller.signal,

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Wait for the in-flight clone to finish (listen for repos:clone-progress completion) and reuse its result rather than issuing a second clone.
  2. Dedupe at the caller: track active clone requests by (connectionId, path) and coalesce.
  3. If the entry is stuck (clone crashed without running finally), it is cleared on the next clone's finally — but a main-process restart guarantees a clean set.
  4. Show a UI hint that the destination is already being cloned and offer to focus that clone.
Defensive patterns

Strategy: retry

Validate before calling

// remoteCloneInFlightByPath is module-private; mirror at the caller with a local Set keyed the same way.
import { normalizeRuntimePathForComparison } from '../../shared/cross-platform-path'

const inflight = new Set<string>()
function cloneKey(connectionId: string, clonePath: string): string {
  return `${connectionId}:${normalizeRuntimePathForComparison(clonePath)}`
}
function isCloneAlreadyInFlight(connectionId: string, clonePath: string): boolean {
  return inflight.has(cloneKey(connectionId, clonePath))
}

Type guard

function isCloneAlreadyInProgress(err: unknown): boolean {
  return err instanceof Error && err.message === 'A clone is already in progress for this SSH destination'
}

Try / catch

const key = cloneKey(connectionId, clonePath)
if (inflight.has(key)) {
  // reuse the in-flight clone's result instead of issuing a second one
  return waitForCloneResult(key)
}
inflight.add(key)
try {
  return await cloneRemoteRepo(store, mainWindow, { connectionId, url, destination })
} finally {
  inflight.delete(key)
}

Prevention

When it happens

Trigger: Two clone requests for the same connectionId and the same normalized clonePath while the first is still running. Common with double-click, retry storms, or two panes cloning the same repo to the same path.

Common situations: User clicks 'clone' twice rapidly; a workspace-restore clone races an explicit user clone; retry logic in the UI not deduping; orphaned entry from a clone whose finally didn't run (process crash mid-clone).

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/0bb97433d0459122. Report an issue: GitHub.