fix(agent-core): rename-swap managed plugins to avoid Windows EBUSY - #2430
fix(agent-core): rename-swap managed plugins to avoid Windows EBUSY#2430mangeshraut712 wants to merge 1 commit into
Conversation
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 detectedLatest commit: 640a28a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
Related Issue
Fixes #2361
Problem
Updating a managed plugin on Windows fails with
EBUSY: resource busy or locked, rmdirwhen the plugin's MCP server child still has the managed directory as its cwd (or holds open file handles inside it).What changed
agent-corePluginManager: move the live managed root aside, publish staging into place, then best-effort delete the previous tree.*-previoussiblings remain when cleanup can complete.Stopping MCP children before swap is still the ideal follow-up; this change removes the hard
rmdirfailure mode that blocks updates today (v2 already used rename-swap; v1 CLI path did not).Checklist
gen-changesetsskill, or this PR needs no changeset. (changeset included)vitest run test/plugin/manager.test.ts— 43 passedMade with Cursor