Repository navigation
Unlock sites stuck behind an operation whose pid now belongs to another process - #6193
Merged
Merged
Conversation
…er process Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
How AI was used in this PR
Claude Code read the report and the site-operation lock, reproduced the stuck site with the released 2.4.0 CLI on a throwaway config, wrote the fix and tests, and checked the before/after behavior with real CLI builds. The scope (including unlocking records from older builds) was decided along the way.
Proposed Changes
A site could stay stuck forever on "Cannot run a site start: an export is already in progress for this site", with no way out short of editing the config by hand. Restarting Studio or the computer didn't help.
Studio marks a site as busy by storing the pid of the process running the operation, and treats it as busy as long as that pid is alive. When the operation's process died without clearing that mark, and its pid was later reused by an unrelated process (after a reboot, or once pids wrap around), Studio kept believing the operation was still running.
studio mcpor the daemon can be indefinitely.Trade-off: right after upgrading from 2.4.0, an operation still running in a 2.4.0 process (most likely a
studio mcpserver kept alive across the update) is no longer protected for its remaining duration.Testing Instructions
Unit tests:
npm test -- apps/cli/lib/tests/site-operations.test.tsTo reproduce with the real CLI, on a throwaway config:
npm run cli:buildexport DEV_CONFIG_DIR=/tmp/s2864/config STUDIO_PROCESS_MANAGER_HOME=/tmp/s2864/pm STUDIO_BASE_PORT=9470node apps/cli/dist/cli/main.mjs site create --path /tmp/s2864/sites/test --skip-browser, thensite stop --path /tmp/s2864/sites/test/tmp/s2864/config/config.json, add"operation": { "pid": <pid of Finder>, "kind": "export" }to the site, which is what 2.4.0 leaves behind after a crash and a pid reuse.site start --path /tmp/s2864/sites/test/Applications/Studio.app/Contents/Resources/bin/node /Applications/Studio.app/Contents/Resources/cli/main.mjs): refused with "an export is already in progress".{ "pid": <pid of Finder>, "kind": "export", "bootTime": <now minus os.uptime() in ms> }, which is what a live operation looks like: this branch refuses the start, as it should.site stop --all, then remove/tmp/s2864.Pre-merge Checklist
🤖 Generated with Claude Code