Skip to content

fix: serialize remote Taskfile clone across processes (fixes #3011) - #3012

Closed
fwh888 wants to merge 1 commit into
go-task:mainfrom
fwh888:fix/git-cache-cross-process-lock-3011
Closed

fix: serialize remote Taskfile clone across processes (fixes #3011)#3012
fwh888 wants to merge 1 commit into
go-task:mainfrom
fwh888:fix/git-cache-cross-process-lock-3011

Conversation

@fwh888

@fwh888 fwh888 commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Fixes #3011: concurrent Task processes cloning the same remote Git Taskfile now serialize via a cross-process flock.

  • lockRepoCache takes an exclusive file lock (lock file lives in os.TempDir()/task-git-repos-locks, outside the cache dir that CleanGitCache removes)
  • getOrCloneRepo acquires it before the cache check and clone
  • The existing per-process mutex stays for goroutine serialization

Tests

  • New TestLockRepoCache_MutuallyExclusive: second lock blocks until first releases
  • go test ./taskfile/ passes

Fixes #3011

…3011)

The in-process sync.Mutex only protects goroutines within one Task
process. When an IDE extension, shell completion and a terminal invoke
Task at the same time, two processes can clone the same repo cache dir
concurrently and corrupt it.

- New lockRepoCache() takes an exclusive flock on a lock file outside
  the cache dir (which CleanGitCache removes)
- getOrCloneRepo acquires it before the cache check / clone
- Test: two acquisitions of the same key are mutually exclusive
  (second blocks until release)
@trulede

trulede commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This is a uniquely poor PR! Please don't open any more PRs with AI generated code.

@trulede trulede closed this Sep 7, 2026
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.

Race condition between concurrent Task processes when cloning remote Git Taskfiles

2 participants