Skip to content

fix(agent-core): rename-swap managed plugins to avoid Windows EBUSY - #2430

Open
mangeshraut712 wants to merge 1 commit into
MoonshotAI:mainfrom
mangeshraut712:fix/plugin-managed-update-ebusy
Open

fix(agent-core): rename-swap managed plugins to avoid Windows EBUSY#2430
mangeshraut712 wants to merge 1 commit into
MoonshotAI:mainfrom
mangeshraut712:fix/plugin-managed-update-ebusy

Conversation

@mangeshraut712

Copy link
Copy Markdown
Contributor

Related Issue

Fixes #2361

Problem

Updating a managed plugin on Windows fails with EBUSY: resource busy or locked, rmdir when the plugin's MCP server child still has the managed directory as its cwd (or holds open file handles inside it).

What changed

  • Port the agent-core-v2 rename-then-swap publish path into agent-core PluginManager: move the live managed root aside, publish staging into place, then best-effort delete the previous tree.
  • Install failures roll the previous managed copy back into place.
  • Extend the overwrite test to assert no leftover *-previous siblings remain when cleanup can complete.

Stopping MCP children before swap is still the ideal follow-up; this change removes the hard rmdir failure mode that blocks updates today (v2 already used rename-swap; v1 CLI path did not).

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset. (changeset included)
  • vitest run test/plugin/manager.test.ts — 43 passed

Made with Cursor

Replacing a managed plugin used to rm the live directory in place.
On Windows that fails when the plugin's MCP child still holds that
directory as cwd. Publish via rename-aside + staging swap and treat
cleanup of the previous tree as best-effort.

Fixes MoonshotAI#2361
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 640a28a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 640a28a92e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

github,
parsed,
});
this.records.set(id, record);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Defer mutating plugin records until persistence succeeds

If writeInstalled/the final rename in persist() fails here (for example due to disk, permission, or antivirus/file-lock issues), the outer catch now rolls the managed directory back but leaves this.records pointing at the just-built record. A failed update can then appear installed for the rest of the process, and a later setEnabled/persist can write metadata for the rolled-back tree; build a next map and assign it only after persistence succeeds, or restore the old map in the catch.

Useful? React with 👍 / 👎.

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.

[Windows] Plugin update fails with EBUSY: managed plugin directory locked by its own running MCP server child process

1 participant