Add "Retry" button to ReportError component
See original GitHub issueFeature Description
Currently when the user encounters an error that causes ReportError to be displayed, there is no way to retry the request. We should add a “retry” button that invalidates the request’s resolver and forces the request to be tried again.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- A “Retry” button should be added to the
ReportErrorcomponent whenever the return value fromgetErrorForSelectorcontains theselectorDataobject. - Other than that, there are a few exceptions where the button should not be shown if any of the following is true:
- If the
selectorNameis notgetReport(because then it could be any other type of error that is not from the report API request) - @eugene-manuilov raised this earlier today, and it makes sense to me. - If the error is an “insufficient permissions error”, i.e. the user doesn’t have access to this data. In that case, they will have to coordinate with the admin who does have access so that they can get access to. That’s not exactly a quick task (unless they’re sitting right next to them), so we probably shouldn’t show the Retry button there as it’s not going to help.
- If the error is a “permission scope error”, i.e. the user hasn’t granted certain OAuth scopes. In that case they will see a banner notification to fix this anyway, and retrying the request won’t do it.
- If the error has a
reconnectURLwith it, i.e. there is already a CTA URL present which can fix the problem - again retrying the request won’t do it in this case.
- If the
- When activated, the button should use this code:
dispatch(selectorData.storeName)
.invalidateResolution(
selectorData.name,
selectorData.args
);
to clear the error.
Implementation Brief
- In
assets/js/components/notifications/CTA.jscomponent:- Take two new props
retrywhich is a boolean andonRetrywhich is a function.- Both props are optional.
- When the
retryprop istrue, render aButtoncomponent with the following:onClickshould beonRetry.- Children should be translated string
Retry.
- Take two new props
- In
assets/js/components/ReportError.jscomponent:- When the passed
errorprop has aselectorDataobject-- Define a callback function for the retry handler which dispatches the
invalidateResolutionaction like it is shown in the AC. - Pass
retryto theCTAelement. - Pass the aforementioned retry handler function to the
onRetryprop of theCTAelement.
- Define a callback function for the retry handler which dispatches the
- When the passed
Test Coverage
- Add story with the Retry Button on
assets/js/components/ReportError.stories.js. We can do it without waiting for the blocker issue by passing an object of same shape as theerrorprop.
QA Brief
- Ensure the newly added story has a
Retrybutton. The following link will work once the PR gets merged: https://google.github.io/site-kit-wp/storybook/develop/?path=/story/components-reporterror--report-error-with-retry-button Otherwise, it can be found here: https://google.github.io/site-kit-wp/storybook/pull/5337/?path=/story/components-reporterror--report-error-with-retry-button - Verify the
Retrybutton appears as per the AC, if the error is thegetReportdata error and is not any of the following:- Is not an “insufficient permissions error”
- Is not a “permission scope error”
- Is not an auth error that has
error.data. reconnectURL
- A
getReporterror can be simulated by using an HTTP proxy/request proxy and having requests to the Site Kit API (example:http://sitekit.10uplabs.com/wp-json/google-site-kit/v1/modules/search-console/data/searchanalytics) fail/abort. This should cause the “retry” button to appear, and when clicked trigger the request again. - Refer to this comment. It’s almost the same as the AC.
Update:
@felixarntz spotted an issue with Adsense getReport errors (refer to this comment).
Also, refer the investigation and the proposed solution by @tofumatt here.
- To replicate this using Proxyman, set a breakpoint with a wildcard for the API requests like so
http://sitekit.10uplabs.com/wp-json/google-site-kit/v1/*. - The domain has to be your local or the test site’s domain.
- Abort all the
reportrequests. - Verify the
Retrybutton appears. - When clicking the
Retrybutton the requests should be sent and this time execute the requests from the Proxyman. - Verify the data appears on the widget.
Changelog entry
- Add a “retry” button for HTTP requests that encountered an error on the dashboard.
Issue Analytics
- State:
- Created a year ago
- Comments:23 (4 by maintainers)
Top Results From Across the Web
Swift "retry" logic on request - alamofire - Stack Overflow
I simplified the logic by having only success and failure callbacks, a progress should not be that hard to add. So, assuming that...
Read more >338899 - "Try again" button for loading unpacked extensions
I've got it mostly implemented. My only question is how to send the retry message from the .cc side in ExtensionErrorReporter.ReportError(). I' ...
Read more >Daily Health Report Error - TechNet - Microsoft
I've had the pleasure of re-installing SCE 3 times now and have it working, except that the Daily health report does not run....
Read more >CCS/TMS570LS3137: IcePick: Error connecting to the target ...
Part Number: TMS570LS3137 Tool/software: Code Composer Studio Hi, ... to device,the device report error 2131,and I press the reset button ...
Read more >Error message definitions for WebSphere® Application ... - IBM
Resolution: Restart the server and try again. Message: lib_security: updateOSLibpath: Setting the LIBPATH for GSK failed, could not append /usr/ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@hussain-t @bethanylang @aaemnnosttv @tofumatt Based on today’s conversation, I suggest the following refinement here:
ReportErrors (i.e. the red border in-widget errors), we limit it by adding a number of exceptions where the button should not be shown if any of the following is true:selectorNameis notgetReport(because then it could be any other type of error that is not from the report API request) - @eugene-manuilov raised this earlier today, and it makes sense to me.reconnectURLwith it, i.e. there is already a CTA URL present which can fix the problem - again retrying the request won’t do it in this case.In order to implement the last three without duplicating too much, we should rely on helper functions like
isInsufficientPermissionsError( error ),isPermissionScopeError( error ), andisAuthError( error )which we can then call here. The last two should also be used in the existingdispatchAPIErrorfunction (which I used as a reference to define the last two conditions above). The first two helper functions already exist, so let’s add anisAuthErrorto them. We can then use these small helpers in bothReportErroranddispatchAPIErroras applicable.Let me know what you think.
@mohitwp When I tested this I was using an HTTP proxy (Proxyman, though Charles or other proxies would work too) and adding a breakpoint to all requests using Tools > Breakpoints > Add Rule:
Whatever HTTP proxy you’re using, adding breakpoints to
http://sitekit.10uplabs.com/wp-json/google-site-kit/v1/*will let you control the response from those requests. You can changehttp://sitekit.10uplabs.comto whatever your testing site’s URL is, and this will let you control whether the Site Kit API request goes through or not.If you abort the request, it will be an HTTP fetch failure that should trigger the retry button. It’s exactly what I did when testing:
Alternatively, you could probably insert code into the plugin to cause that request to fail, eg: https://github.com/google/site-kit-wp/blob/affa782aab7b74ad44d8dbb55cdc6a5f2d854806/includes/Modules/Search_Console.php#L213. Adding a
die('Foo.');right before this line should work, but I proposed the HTTP proxy because it means using exactly the production code to test.Does that help?