Fix crash when deleting a site - #300
Merged
Merged
Conversation
sejas
approved these changes
Jun 27, 2024
Member
There was a problem hiding this comment.
I tested it and the site context is still working while it doesn't crash when deleting sites.
I also tested executing wp-cli from the terminal and it worked as expected.
Here is the output of canceled and skipped wp-cli commands for a deleted site.
directory: /Users/macbookpro/Studio/dotcom-local-site
mode: wordpress
php: 8.1
wp: latest
WordPress latest folder already exists. Skipping download.
SQLite folder already exists. Skipping download.
Server running at http://localhost:8881
Saved user data to /Users/macbookpro/Library/Application Support/Studio/appdata-v1.json
==== executing wp-cli command theme list --format=json
==== executing wp-cli command plugin list --format=json --status=active
==== response wp-cli command { stdout: '[]', stderr: '' }
==== response wp-cli command {
stdout: '[{"name":"twentytwentyfour","status":"active","update":"none","version":"1.1","update_version":"","auto_update":"off"},{"name":"twentytwentythree","status":"inactive","update":"none","version":"1.4","update_version":"","auto_update":"off"},{"name":"twentytwentytwo","status":"inactive","update":"none","version":"1.7","update_version":"","auto_update":"off"}]',
stderr: ''
}
==== executing wp-cli command plugin list --format=json --status=active
==== response wp-cli command { stdout: '[]', stderr: '' }
==== executing wp-cli command theme list --format=json
==== response wp-cli command {
stdout: '[{"name":"twentytwentyfour","status":"active","update":"none","version":"1.1","update_version":"","auto_update":"off"},{"name":"twentytwentythree","status":"inactive","update":"none","version":"1.4","update_version":"","auto_update":"off"},{"name":"twentytwentytwo","status":"inactive","update":"none","version":"1.7","update_version":"","auto_update":"off"}]',
stderr: ''
}
==== executing wp-cli command plugin list --format=json --status=active
Deleting site 668a9fe8-875f-46db-9306-71cb8f74377a
Loaded user data from /Users/macbookpro/Library/Application Support/Studio/appdata-v1.json
Stopping server with ID 668a9fe8-875f-46db-9306-71cb8f74377a
Server stopped
==== wp-cli command canceled plugin list --format=json --status=active
==== skipping wp-cli command because site is deleted 668a9fe8-875f-46db-9306-71cb8f74377a theme list --format=json
Saved user data to /Users/macbookpro/Library/Application Support/Studio/appdata-v1.json
Killed processes using port 8881
Screenshots when running sites:
Screenshot without sites:
Comment on lines
85
to
86
|
|
||
| const messageId = +this.lastMessageId; | ||
| const messageId = this.lastMessageId++; | ||
| process.postMessage( { message, messageId, data } ); |
| if ( ! server ) { | ||
| throw new Error( 'Site not found.' ); | ||
| } | ||
| return server.executeWpCliCommand( args ); |
Member
There was a problem hiding this comment.
I like this way of executing wp-cli commands
dcalhoun
approved these changes
Jun 27, 2024
dcalhoun
left a comment
Member
There was a problem hiding this comment.
Fantastic work! Very elegant solution. 👏🏻 Thank you for addressing this.
The plan succeeded for me.
My suggestions are for my own education and small preferences. They should not block this PR. 🚀
…-cli process Co-authored-by: David Calhoun <github@davidcalhoun.me>
Co-authored-by: David Calhoun <github@davidcalhoun.me>
fluiddot
force-pushed
the
fix/crash-delete-site
branch
from
June 27, 2024 16:24
817ea71 to
3b85c67
Compare
Contributor
Author
|
Heads up that I had to rebase this branch after an issue when merging with |
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.
Fixes 7907-gh-Automattic/dotcom-forge.
Proposed Changes
This PR aims to solve two cases related to executing
wp-clicommands at the same time a site is being deleted:wp-clifail due to the inability to access site files.wp-cliprocesses before deleting the site.wp-cliprocess to sites. This way we can kill the process before deletion.wp-cliprocess.Testing Instructions
Preparation:
wp-clicommands:Chat context fetches plugins and themes
wp-clicommandplugin listis executed successfully for the default selected site.wp-clicommandtheme listis executed successfully for the default selected site.wp-clicommandplugin listis executed successfully for the default selected site.wp-clicommandtheme listis executed successfully for the default selected site.Delete running site doesn't crash
wp-clicommandplugin listis invoked but canceled.wp-clicommandtheme listis skipped because the site is deleted.Check open processes
electron.wp-cliexecutor.Pre-merge Checklist