-
Notifications
You must be signed in to change notification settings - Fork 846
Jetpack Dashboard: More meaningful error notices. #16883
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
|
Thank you for the great PR description! When this PR is ready for review, please apply the E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16883 Scheduled Jetpack release: September 1, 2020. |
If Jetpack encounters a communication error, it suggest reconnecting. That doesn't always help. In fact, there is a myriad of other reasons why the error might be thrown, and blindly suggesting to restore connection might only mislead users. This commit introduces different types of error: - `ApiError` is clearly a connection error, and might be solved by disconnecting. - `JsonParseError` is a JSON parsing issue. This usually means there's an error output included into the JSON response, so we suggest the user to check the error log, and don't show the "Restore Connection" button. - Anything else: we do nothing, as we have no idea what's going on. Most likely it's a network issue, and we don't have an easy solution for that.
c8d178b to
56b3fd2
Compare
jeherve
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.
That's going to be a nice improvement 🤩
I wonder if we should consider adding whatever raw message we may be getting in some cases from the API response to the end of the error messages. In some cases, it may give more information as to what's happening?
The error notices are improved even further: - The `error_code` is being displayed in the notice, which will make debugging much simpler if the user reaches out to tech support. - The "Missing Site ID" error is also displayed in the notice, and clicking "Restore Connection" actually solves the problem.
|
@jeherve that's a great idea, I added that 👍
Please re-review the PR. |
leogermani
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.
This is great @sergeymitr, thanks for that!
I also tested forcing some error to the site request by adding this to my .htaccess
RewriteRule ^wp-json\/jetpack\/v4\/site$ - [R=503,L]
And it worked as expected!
* master: (23 commits) Premium Blocks: set blocks availability (#16898) Compat Package: Fix method declaration compatibility (#16900) Jetpack Dashboard: More meaningful error notices. (#16883) Connection REST API: Unit test for the `remote_authorize` request. (#16879) use blog token to request jetpack.updateBlog (#16698) Improve Story block media loading (#16663) Simplify error notices for broken connections (#16655) Use new heartbeat package (#16285) wrap-paid-block: remove component. deprecated. (#16895) Social Previews: improve preview description handling (#16889) Stats module use blog token (#16727) Form Block: add a new Consent Field, a new Newsletter setting, and a new newsletter variation (#16808) AAG: Backup card, fall back to VP content in case of /rewind API error. (#16867) Donations: Fix dependencies (#16892) Creative Mail: update option to lowercase (#16861) Premium Blocks: Implement the new design (#16611) Requests to Stats CSV use the blog token (#16716) Update spacing around sharing buttons to avoid no bottom margin below the customize link. (#16811) Jetpack SSO: Cleaning up the `requestNonce` API request. (#16830) Donations: Update plans when currency changes (#16844) ...
) If Jetpack encounters a communication error, it suggest reconnecting. That doesn't always help. In fact, there is a myriad of other reasons why the error might be thrown, and blindly suggesting to restore connection might only mislead users. This commit introduces different types of error: - `ApiError` is clearly a connection error, and might be solved by disconnecting. - `JsonParseError` is a JSON parsing issue. This usually means there's an error output included into the JSON response, so we suggest the user to check the error log, and don't show the "Restore Connection" button. - Anything else: we do nothing, as we have no idea what's going on. Most likely it's a network issue, and we don't have an easy solution for that. Other improvements: - The `error_code` is being displayed in the notice, which will make debugging much simpler if the user reaches out to tech support. - The "Missing Site ID" error is also displayed in the notice, and clicking "Restore Connection" actually solves the problem.
If Jetpack encounters a communication error, it suggest reconnecting.
That doesn't always help. In fact, there is a myriad of other reasons why the error might be thrown, and blindly suggesting to restore connection might only mislead users.
Changes proposed in this Pull Request:
This PR introduces different types of error:
ApiErroris clearly a connection error, and might be solved by reconnecting.JsonParseErroris a JSON parsing issue. This usually means there's an error output included into the JSON response, so we suggest the user to check the error log, and don't show the "Restore Connection" button.Does this pull request change what data or activity we track or use?
No.
Testing instructions:
yarn watch, please rebuild the JS after checking out the branch.Connection Error
blog_token, refresh the dashboard and wait until it loads.blog_tokenshould get restored.JSON parsing error
Jetpack_Core_Json_Api_Endpoints::get_site_data()API endpoint method:jetpack/_inc/lib/class.core-rest-api-endpoints.php
Line 1755 in de74386
echo 'something';) to break the output JSON.Why not both?
This is a special use case that needed to be fixed separately, so we need to test it too.
10. Keep your
echo 'something';in place, but in addition to that break theblog_token. So the connection will be broken, but the error response will also contain invalid JSON.11. Reload the Dashboard, and confirm that you see the "update to communicate" error notice (see example above). The "Restore Connection" button must not appear, as it's pointless trying to restore the connection as we won't be able to parse the response anyway.
12. Fix the JSON by removing your
echo 'something';line from theJetpack_Core_Json_Api_Endpoints::get_site_data()method. Keep the token broken for now.13. Reload the dashboard. You should see the "Restore Connection" error notice.
14. Click on the "Restore Connection", the page should reload, the error notice should no longer appear.
Thanks for testing! 🙂
Proposed changelog entry for your changes: