Repository navigation
fix(git-clone): clean up the half-built destination after a timeout - #2294
SeanLiu326 wants to merge 3 commits into
Conversation
agentCompact's busy check went stale the moment it passed: between it and the sidecar call sit the settings read, the session detail, and the launch resolution, so a prompt submitted in that window started a turn this compaction then ran against mid-stream. Hold the same session operation the prompt and abort paths use, from before the check until the call settles; the setup body moves to a helper so the handler reads as guard -> work -> release.
sessionDelete had no running guard and held no session operation, so a delete cascaded away the rows a live turn was still streaming into: every later outbox append failed its foreign key, and the renderer kept receiving events for a session that no longer existed. Fork already refuses a running session; delete now does too, and holds the same session operation so a turn starting between the check and the host call cannot slip through either.
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.
vastsa
left a comment
There was a problem hiding this comment.
This clone-timeout PR also contains the agentCompact/sessionDelete changes from #2292. In particular, session-ipc.ts is byte-identical (blob a89bde4a18a56ad18843dc51196f0b0d08ec34f6) to the #2292 head where the queued-start deletion race was independently reproduced: delete checks activeTurns before awaiting acquireSessionOperation, a pending prompt registers a live turn while holding that operation, then delete acquires it and deletes the running session without rechecking. See the production-handler/production-coordination diagnostic and requested regressions in #2292 (review) . This review reuses that executed evidence for identical code; it does not claim a fresh clone E2E run.
Please remove the unrelated IPC changes from this clone-specific PR (preferred minimal scope), or complete the authoritative activeTurns check inside the acquired lock and its behavioral regression coverage before landing. The clone cleanup itself still needs independent data-ownership/lifecycle validation; I have not accepted it merely from the added injected-run test.
|
I checked this on macOS with real git 2.50: SIGTERM during |
|
Thanks @SeanLiu326 — your clone-cleanup commit landed in #2357 with authorship preserved, together with the requested follow-ups (wait for the killed process tree to close before cleaning, only remove a destination this clone created, retry/log cleanup failures). The agentCompact/sessionDelete commits were left out; they remain under review in #2290/#2292. Closing as superseded. |
Fixes #2293.
What
A timed-out clone was killed with git inside its checkout, and the half-built destination stayed behind — every retry of the same name then hit
CONFLICT: "<name>" already exists in that folderuntil the user found and deleted the residue by hand.The change
The
TIMEOUTpath removes the destination before throwing: recursive delete for a real directory, plain unlink when it is a symlink (never recurse into a link target), and best-effort silence when git died before creating anything.Tests
cloneGitRepository cleans up a half-built destination after a timeout: the injectedruncreates the checkout (as git would) and returnsTIMEOUT; the assertion is theTIMEOUTrejection plus the destination being gone. Verified failing on unpatched source and passing after (13/13).