-
Notifications
You must be signed in to change notification settings - Fork 53
Fix crash when deleting a site #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
|
|
||
| const messageId = +this.lastMessageId; | ||
| const messageId = this.lastMessageId++; | ||
| process.postMessage( { message, messageId, data } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
| if ( ! server ) { | ||
| throw new Error( 'Site not found.' ); | ||
| } | ||
| return server.executeWpCliCommand( args ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this way of executing wp-cli commands
dcalhoun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Co-authored-by: David Calhoun <[email protected]>
817ea71 to
3b85c67
Compare
|
Heads up that I had to rebase this branch after an issue when merging with |
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