Skip to content

fix: serialize concurrent marketplace repo clones via SequencerByKey#301289

Merged
connor4312 merged 4 commits intomainfrom
copilot/fix-could-not-create-work-tree-dir
Mar 13, 2026
Merged

fix: serialize concurrent marketplace repo clones via SequencerByKey#301289
connor4312 merged 4 commits intomainfrom
copilot/fix-could-not-create-work-tree-dir

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

Adding a new plugin marketplace could trigger concurrent ensureRepository calls for the same repo. Both would see the directory missing, both would attempt git clone, and the second would fail with fatal: could not create work tree dir '...': File exists.

  • AgentPluginRepositoryService: add _cloneSequencer: SequencerByKey<string> and wrap ensureRepository body in _cloneSequencer.queue(marketplace.canonicalId, ...). Concurrent calls for the same canonical ID are serialized — the second waits for the first, then finds the directory already exists and returns early.
  • Test: add a test that fires two concurrent ensureRepository calls for the same marketplace and asserts _git.cloneRepository is invoked exactly once.

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…tplace repo

Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error creating work tree dir for plugin marketplace fix: serialize concurrent marketplace repo clones via SequencerByKey Mar 12, 2026
Copilot AI requested a review from connor4312 March 12, 2026 23:24
@connor4312 connor4312 marked this pull request as ready for review March 12, 2026 23:49
Copilot AI review requested due to automatic review settings March 12, 2026 23:49
@connor4312 connor4312 enabled auto-merge (squash) March 12, 2026 23:49
@vs-code-engineering vs-code-engineering bot added this to the 1.112.0 milestone Mar 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Prevents race conditions when multiple callers attempt to clone the same plugin marketplace repository concurrently by serializing ensureRepository work, and adds a regression test around concurrent calls.

Changes:

  • Add a SequencerByKey<string> to serialize concurrent ensureRepository calls.
  • Wrap ensureRepository clone flow inside the sequencer queue.
  • Add a browser test that fires concurrent ensureRepository calls and asserts clone happens once.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/vs/workbench/contrib/chat/browser/agentPluginRepositoryService.ts Serializes ensureRepository to avoid concurrent git clone into the same target directory.
src/vs/workbench/contrib/chat/test/browser/plugins/agentPluginRepositoryService.test.ts Adds a concurrent-call test asserting _git.cloneRepository is invoked only once.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@connor4312 connor4312 merged commit e7e6cbe into main Mar 13, 2026
20 checks passed
@connor4312 connor4312 deleted the copilot/fix-could-not-create-work-tree-dir branch March 13, 2026 01:09
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.

Fatal: could not create work tree dir when adding new plugin marketplace

4 participants