question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add new selectorData object in getErrorForSelector

See original GitHub issue

Feature 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 to createErrorStore()
    • 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

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 any selectorData 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 the selectorData attribute.
  • If storeName is found, return the selectorData attribute with the storeName, name, and args attributes. These should be the storeName 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 a storeName set and that the selectorData attributes on getErrorForSelector 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 when createErrorStore without a storeName is used, the getErrorForSelector selector doesn’t return a selectorData 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 the getURLChannels 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:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
wpdarrencommented, Jun 14, 2022

@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.

0reactions
jimmymadoncommented, Jun 16, 2022

QA ✅

  • Verified the new selectorData object for mocked errors and real errors in the plugin.
  • Screenshots: MockedData RealErrorData RealErrorData2
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found