Add new selectorData object in getErrorForSelector
See original GitHub issueFeature Description
In order for us to be able to retry requests that encountered errors, we need to be able to invalidate their selectors. To do this, we need to return information about the selector that caused an error to be dispatched in the getErrorForSelector
selector.
See the design doc section for more detail: https://docs.google.com/document/d/1QIruz3fJSDQJ2cILtBHlU6ow8esyaVS3mcuaqt5QQR8/edit?resourcekey=0-nM2tn9DOjjHDWTtspbERkA#heading=h.xleqo0mvx6mv
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
getErrorForSelector
selector should return a new object whenever possible:selectorData
. This object should contain:- a
storeName
attribute, with the name of the store supplied tocreateErrorStore()
- a
name
attribute, which is the name of the selector that caused the error - an
args
attribute, which is an array of the arguments (if any) passed to the selector
- a
Implementation Brief
- Check for the
storeName
value for the current error store (based on the work done in #5235). If not available, don’t return anyselectorData
because we shouldn’t ever return “not enough” data to allow a reset of an error’s resolver.- If
storeName
is a required attribute in #5235,getErrorForSelector
should always return theselectorData
attribute.
- If
- If
storeName
is found, return theselectorData
attribute with thestoreName
,name
, andargs
attributes. These should be thestoreName
from above, the selector’s name, and the array of arguments passed to the selector respectively.
Test Coverage
- Add tests that ensure these attributes are present when
createErrorStore
is used with astoreName
set and that theselectorData
attributes ongetErrorForSelector
match the selector whose resolver encountered an error (use various types of arguments and no arguments at all for the selector). - If
storeName
ends up being an optional attribute based on #5235’s implementation: add tests to ensure whencreateErrorStore
without astoreName
is used, thegetErrorForSelector
selector doesn’t return aselectorData
attribute.
QA Brief
- This adds the
selectorData
to errors, so the best way to QA this is to run through some of the selectors that produces an error state. For example, in the browser console, set an error state for thegetURLChannels
selector:
googlesitekit.data.dispatch('modules/adsense').receiveError( {
code: 403,
message: 'Forbidden',
data: {
status: 403,
reason: 'forbidden',
},
}, 'getURLChannels', [100, 200] );
- Run the selector to verify it contains the
selectorData
object with the properties that matches the selector name and args:
googlesitekit.data.select( 'modules/adsense' ).getErrorForSelector( 'getURLChannels', [100, 200] )
- Ensure this works for other selectors too.
Changelog entry
- Update the
getErrorForSelector
selector to include selector details in the returning error.
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
How to fix circular reference in javascript object?
If any of the added elements contain a reference to the list itself, that would result in a circular structure, which cannot be...
Read more >Add selectorData to all selector-related errors returned by getError ...
Create a new error store selector, getSelectorDataForError which takes an error object as its argument. Lookup the selector data, i.e. name and args ......
Read more >TypeError: cyclic object value - JavaScript - MDN Web Docs
The JavaScript exception "cyclic object value" occurs when object ... if (seen.has(value)) { return; } seen.add(value); } return value; ...
Read more >Feature: add better branch protection documentation and adjust ...
Refactor pylint/config modules to avoid using deprecated optparse module. 1, 2021-05-09, 2022-08-20. Add new selectorData object in getErrorForSelector, 1, 2022 ...
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 since I am unable to come up with the code for the different selectors, and to be completely honest, have no idea what I am looking out for, I would feel comfortable having an engineer looking over this.
I’ll flag it
QA:Eng
to be on the safe side.QA ✅
selectorData
object for mocked errors and real errors in the plugin.