Skip to content

fix(git-clone): clean up the half-built destination after a timeout - #2357

Merged
vastsa merged 2 commits into
mainfrom
fix/clone-timeout-cleanup
Nov 15, 2026
Merged

vastsa merged 2 commits into
mainfrom
fix/clone-timeout-cleanup

Conversation

@vastsa

@vastsa vastsa commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Completes #2294 (author's commit preserved) with the changes requested in review, scoped to the clone path only (the unrelated agentCompact / sessionDelete commits are not included).

  • runGitClone resolves a timeout only after close (git and every helper holding its stdio exited), bounded by a 15 s grace then SIGKILL, so cleanup no longer races live writers on Windows.
  • Cleanup only runs for a destination that was absent (lstat) before git started, retries EBUSY/ENOTEMPTY via fs.rm maxRetries, and logs non-ENOENT failures.

Tests: node --test apps/desktop/test/git-clone.test.mjs 17/17 (real child processes for the delayed-exit, SIGTERM-ignored and normal-exit paths; injected run for cleanup and the pre-existing entry).

fixes #2293
Supersedes #2294

SeanLiu326 and others added 2 commits November 15, 2026 18:11
A timed-out clone was killed with git inside its checkout, and the
half-built destination stayed behind: every retry of the same name hit
CONFLICT ("already exists in that folder") until the user found and
deleted the residue by hand. The timeout path now removes the
destination — unlinking it instead of recursing when it is a symlink —
and the removal is best-effort for the case where git never created it.
Resolving the timeout right after SIGTERM let the cleanup race a git
process tree that was still writing; on Windows `kill` is
TerminateProcess and helpers such as git-remote-https keep running, so
the removal failed with EBUSY and the residue stayed behind. The run now
waits (bounded, then SIGKILL) for `close`, which only fires once every
process holding the clone's stdio has exited.

Cleanup is limited to a destination that was absent before git started,
retries transient Windows lock errors, and logs a failure instead of
swallowing it.

fixes #2293
@vercel

vercel Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pi-desktop Error Error Nov 15, 2026 10:24am UTC

@aiuo-codepilot aiuo-codepilot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIUO CodePilot · Preliminary review

Diff-only preliminary review of the timeout/cleanup changes to runGitClone and cloneGitRepository plus their tests. The staged sequencing (resolve on close or after a kill grace, cleanup only for a destination proven absent before spawn) is coherent and the tests cover the described paths. No concrete behavioral defect is evidenced in the added lines, but no runtime execution, test run, Windows behavior, or full-file integration with surrounding code could be verified here.

No evidenced findings in the supplied diff.

Head: 73da9a3
Base: 525ec49
CI: success; mergeable: true.

Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.

@vastsa
vastsa merged commit 2dd99ba into main Nov 15, 2026
7 of 8 checks passed

This branch was previously deployed

1 inactive deployment
Preview – pi-desktop-docs — 73da9a37 Deployed Nov 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git clone timeout leaves a half-built destination; every same-name retry hits CONFLICT

2 participants